R/utils-spatial-filter.R
spatial_filter.Rd
prepare_spatial_filter()
prepares a named list with ESRI JSON geometry for
use as a spatial filter based on a a sfc
, sfg
, or bbox
input object.
match_spatial_rel()
takes a scalar character vector with a predicate name
to a type of ESRI spatial relation.
Usage
prepare_spatial_filter(
filter_geom,
crs,
predicate,
error_call = rlang::caller_env()
)
match_spatial_rel(predicate, error_call = rlang::caller_env())
Arguments
- filter_geom
an object of class
bbox
,sfc
orsfg
used to filter query results based on a predicate function.- crs
a representation of a coordinate reference system.
- predicate
Spatial predicate to use with
filter_geom
. Default"intersects"
. Possible options are"intersects"
,"contains"
,"crosses"
,"overlaps"
,"touches"
, and"within"
.- error_call
default
rlang::caller_env()
.
Value
prepare_spatial_filter()
returns a named list with the
geometryType
, geometry
(as Esri JSON), and spatial relation predicate.
match_spatial_rel()
returns one of the following spatial binary predicates:
esriSpatialRelIntersects
esriSpatialRelContains
esriSpatialRelCrosses
esriSpatialRelOverlaps
esriSpatialRelTouches
esriSpatialRelWithin
Details
Using sfc
objects as filter_geom
If an sfc
object is provided it will be transformed to the layers spatial
reference. If the sfc
is missing a CRS (or is an sfg
object) it is
assumed to use the same spatial reference as the FeatureLayer. If the sfc
object has multiple features, the features are unioned with
sf::st_union()
. If an sfc
object has MULTIPOLYGON
geometry, the features
are unioned before being cast to POLYGON
geometry with sf::st_cast()
. All
geometries are checked for validity before conversion.