as_esri_geometry {arcgisutils}R Documentation

Create Esri geometry objects

Description

These functions convert R objects to Esri json representations. There are three types of representations. These are, from smallest to largest, a geometry object, a feature and a feature set.

Usage

as_esri_geometry(x, crs = 4326, ..., call = rlang::caller_env())

as_esri_features(x, ..., call = rlang::caller_env())

as_esri_featureset(x, ...)

as_geometry(x, crs, ...)

as_features(x, ..., call = rlang::caller_env())

as_featureset(x, ...)

Arguments

x

an sf or sfc class object

crs

the coordinate reference system of the FeatureSet. Must be interpretable by sf::st_crs()

...

additional arguments passed on to methods.

call

The execution environment of a currently running function, e.g. call = caller_env(). The corresponding function call is retrieved and mentioned in error messages as the source of the error.

You only need to supply call when throwing a condition from a helper function which wouldn't be relevant to mention in the message.

Can also be NULL or a defused function call to respectively not display any call or hard-code a code to display.

For more information about error calls, see Including function calls in error messages.

Details

The ⁠_esri_⁠ infix indicates that the input object will be converted directly into the Esri JSON representation. If there is no ⁠_esri_⁠ infix, the object will be converted into the appropriate list structure requiring only jsonify::to_json(x, unbox = TRUE) to convert to Esri JSON.

Geometry object contain the coordinates for a geometry. Features are geometries that have associated attributes with them. This would be similar to a row in an sf object. FeatureSets are a list of features that have additional metadata fields such as spatialReference, geomtryType, and fields. FeatureSets correspond to an sf object.

Geometry objects are defined for 5 different types. These are:

Field handling:

Value

a json Esri geometry object

Examples

library(sf)
as_esri_geometry(st_point(c(0, 1, 3, 4)))
as_esri_geometry(st_multipoint(x = matrix(runif(4), ncol = 2)))
as_esri_geometry(st_linestring(x = matrix(runif(2), ncol = 2)))
as_esri_geometry(st_linestring(x = matrix(runif(2), ncol = 2)))

# polygon
m <- matrix(
  c(0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 2, 2, 1, 2, 3, 1, 3, 2, 0, 0, 0),
  ncol = 3,
  byrow = TRUE
)
as_esri_geometry(st_polygon(list(m)))

[Package arcgisutils version 0.2.0 Index]