spMakeSpatialPoints {FIESTA} | R Documentation |
Spatial - Generates an S4 SpatialPoints object from X/Y coordinates.
Description
Generates an S4 SpatialPoints object with defined projection from a data table or matrix including X and Y coordinates, with option to export as an ArcGIS shapefile (*.shp).
Usage
spMakeSpatialPoints(
xyplt,
xyplt_dsn = NULL,
xy.uniqueid = NULL,
xvar = NULL,
yvar = NULL,
xy.crs = 4269,
addxy = FALSE,
exportsp = FALSE,
savedata_opts = NULL
)
Arguments
xyplt |
Data frame object or String. Name of layer with xy coordinates and unique identifier. Can be layer with xy_dsn, full pathname, including extension, or file name (with extension) in xy_dsn folder. |
xyplt_dsn |
String. Name of database or folder were xyplt is. The dsn varies by driver. See gdal OGR vector formats (https://www.gdal.org/ogr_formats.html). |
xy.uniqueid |
String. Unique identifier of xyplt rows. |
xvar |
String. Name of variable in xyplt defining x coordinate. |
yvar |
String. Name of variable in xyplt defining y coordinate. |
xy.crs |
PROJ.4 String or CRS object or Integer EPSG code defining Coordinate Reference System. (e.g., EPSG:4269-Geodetic coordinate system for North America, NAD83). |
addxy |
Logical. If TRUE, adds x and y variables to spatial sf object. |
exportsp |
Logical. If TRUE, exports spatial object. |
savedata_opts |
List. See help(savedata_options()) for a list of options. Only used when exportsp = TRUE. |
Value
spplt |
sf obect with spatial points and defined CRS. |
If exportsp = TRUE, the sf object is written to specified output.
Note
If exportsp=TRUE and a shp output format is specified:
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,
'outshpnm'_newnames.csv. The returned Spatial object will have original
names, before truncating.
If Spatial object has more than 1 record, it cannot be exported.
Author(s)
Tracey S. Frescino
Examples
# Generate an `sf` points object with `spMakeSpatialPoints` for Wyoming plot
# data, stored in `FIESTA`
spMakeSpatialPoints(xyplt = WYplt,
xy.uniqueid = "CN",
xvar = "LON_PUBLIC",
yvar = "LAT_PUBLIC",
xy.crs = 4269)