as_featureset {arcgisutils} | R Documentation |
Create Esri FeatureSet Objects
Description
These functions create an Esri FeatureSet object. A FeatureSet contains an inner array of features as well as additional metadata about the the collection such as the geometry type, spatial reference, and object ID field.
Usage
as_featureset(x, crs = sf::st_crs(x), call = rlang::caller_env())
as_esri_featureset(x, crs = sf::st_crs(x), call = rlang::caller_env())
Arguments
x |
an object of class |
crs |
the coordinate reference system. It must be interpretable by |
call |
The execution environment of a currently running
function, e.g. You only need to supply Can also be For more information about error calls, see Including function calls in error messages. |
References
Examples
library(sf)
# POINT
# create sfg points
xy <- st_sfc(st_point(c(1, 2)))
xyz <- st_sfc(st_point(c(1, 2, 3)))
xym <- st_sfc(st_point(c(1, 2, 3), dim = "XYM"))
as_esri_featureset(xy)
as_esri_featureset(xyz)
as_esri_featureset(xym)
# MULTIPOINT
# vector to create matrix points
set.seed(0)
x <- rnorm(12)
xy <- st_sfc(st_multipoint(matrix(x, ncol = 2)))
xyz <- st_sfc(st_multipoint(matrix(x, ncol = 3)))
xym <- st_sfc(st_multipoint(matrix(x, ncol = 3), dim = "XYM"))
as_esri_featureset(xy)
as_esri_featureset(xyz)
as_esri_featureset(xym)
# LINESTRING
xy <- st_sfc(st_linestring(matrix(x, ncol = 2)))
xyz <- st_sfc(st_linestring(matrix(x, ncol = 3)))
xym <- st_sfc(st_linestring(matrix(x, ncol = 3), dim = "XYM"))
as_esri_featureset(xy)
as_esri_featureset(xyz)
as_esri_featureset(xym)
# MULTILINESTRING
as_esri_featureset(st_sfc(st_multilinestring(list(xy[[1]], xy[[1]]))))
as_esri_featureset(st_sfc(st_multilinestring(list(xyz[[1]], xyz[[1]]))))
as_esri_featureset(st_sfc(st_multilinestring(list(xym[[1]], xym[[1]]))))
# POLYGON
coords <- rbind(
c(0, 0, 0, 1),
c(0, 1, 0, 1),
c(1, 1, 1, 1),
c(1, 0, 1, 1),
c(0, 0, 0, 1)
)
xy <- st_sfc(st_polygon(list(coords[, 1:2])))
xyz <- st_sfc(st_polygon(list(coords[, 1:3])))
xym <- st_sfc(st_polygon(list(coords[, 1:3]), dim = "XYM"))
as_esri_featureset(xy)
as_esri_featureset(xyz)
as_esri_featureset(xym)
# MULTIPOLYGON
as_esri_featureset(st_sfc(st_multipolygon(list(xy[[1]], xy[[1]]))))
as_esri_featureset(st_sfc(st_multipolygon(list(xyz[[1]], xyz[[1]]))))
as_esri_featureset(st_sfc(st_multipolygon(list(xym[[1]], xym[[1]]))))