writeVector,GVector,character-method | R Documentation |
This function saves a GVector
to disk directly from a GRASS session.
By default, files will be of OGC GeoPackage format (extension ".gpkg
"), but this can be changed with the format
argument. You can see a list of supported formats by simply using this function with no arguments, as in writeVector()
, or by consulting the online help page for GRASS module v.out.ogr
(see grassHelp("v.out.ogr")
).
Note that if the vector has a data table attached and at least one numeric or integer column has an NA
or NaN
value, the function will yield a warning like:
Warning 1: Invalid value type found in record 2 for field column_with_NA_or_NaN. This warning will no longer be emitted.
Also note that despite the promise, this warning will be displayed again.
## S4 method for signature 'GVector,character'
writeVector(
x,
filename,
overwrite = FALSE,
format = NULL,
attachTable = TRUE,
...
)
## S4 method for signature 'missing,missing'
writeVector(x, filename)
x |
A |
filename |
Character: Path and file name. |
overwrite |
Logical: If |
format |
Character or
|
attachTable |
Logical: If |
... |
Additional arguments to send to GRASS module |
Invisibly returns a GRaster
(the input, x
). Also saves the vector to disk.
terra::writeVector()
, sf::st_write()
, GRASS module v.out.ogr
(see grassHelp("v.out.ogr")
)
terra::writeVector()
, the GRASS module manual page for v.out.ogr
(see grassHelp("v.out.ogr")
)
if (grassStarted()) {
# Setup
library(terra)
# Example data
madRivers <- fastData("madRivers")
# What file formats can we attempt to write?
writeVector()
# Convert SpatVector to GVector
rivers <- fast(madRivers)
rivers
# Save GVector to disk as GeoPackage
filename <- tempfile(fileext = ".gpkg")
writeVector(rivers, filename)
# Save GVector to disk as ESRI Shapefile
filename <- tempfile(fileext = ".shp")
writeVector(rivers, filename)
# Save GVector to disk as Google Earth KML
filename <- tempfile(fileext = ".klm")
writeVector(rivers, filename)
# Save GVector data table to disk as comma-separated file
filename <- tempfile(fileext = ".csv")
writeVector(rivers, filename)
# Save GVector data table to disk as NetCDF
filename <- tempfile(fileext = ".ncdf")
writeVector(rivers, filename)
# Save GVector data table to disk as Excel file
filename <- tempfile(fileext = ".xlsx")
writeVector(rivers, filename)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.