Exports an sf object to a specified output.
spExportSpatial(sfobj, savedata_opts = NULL)
sf class R object. Spatial object to export.
List. See help(savedata_options()) for a list of options for saving data. If out_layer = NULL, default = 'datsp'.
An sf spatial object is written to outfolder.
Wrapper for sf::st_write function.
If out_fmt='shp':
The ESRI shapefile driver truncates variable
names to 10 characters or less. Variable names are changed before export
using an internal function (trunc10shp). Name changes are output to the
outfolder, 'out_layer'_newnames.csv.
If sf object has more than 1 record, it cannot be exported to a shapefile.
# Set up data from FIESTA
WYbh <- spImportSpatial(system.file("extdata",
"sp_data/WYbighorn_adminbnd.shp",
package = "FIESTA"))
# Export data with spExportSpatial
spExportSpatial(WYbh,
savedata_opts = list(out_dsn = "WYbh.shp",
outfolder = tempdir(),
overwrite_dsn = TRUE))
#> writing to shapefile
#> Writing layer `outdat' to data source
#> `/private/var/folders/kd/4wp69y7d2yd3fxpd1_m64clm0000gn/T/RtmpAkVUHD/outdat.shp' using driver `ESRI Shapefile'
#> Writing 1 features with 11 fields and geometry type Polygon.