yonghah/esri2sf

Feature suggestion: adding optional location and buffer dist parameters to esri2sf

elipousson opened this issue · 1 comments

I use the bbox parameter of esri2sf all the time but I just wrote a get_esri_data() helper function that wraps esri2sf in my new {overedge} package and realized that it may make sense to pull one of the features into the main package.

Drawing on the example of the mapboxapi package, I set up the function so it can accept an sf object (as well as a bounding box) and then apply a buffer before creating the bounding box to pass into the query. But, the ArcGIS FeatureServer query API actually supports a distance parameter in combination with the data passed to geometry as a spatial filter. Ideally, implementing a location parameter could also include:

  • Support for point as well as polygon sf data
  • Access to the spatial relation options for spatial filtering. Those include: "esriSpatialRelIntersects | esriSpatialRelContains | esriSpatialRelCrosses | esriSpatialRelEnvelopeIntersects | esriSpatialRelIndexIntersects | esriSpatialRelOverlaps | esriSpatialRelTouches | esriSpatialRelWithin"
  • Support for setting the units of the distance buffer

I'm currently doing all of this without the API using a wrapper function for sf_buffer but I'm assuming it may be faster for all that processing to take place on the server side. Happy to start working on this once the URL validation branch gets incorporated back into the package.

I made some progress on this by adding support for the spatial relation parameter to my fork of esri2sf and added support for POINT geometry (which works with the "esriGeometryPoint" geometry type).

If anyone is interested in expanding support for other geometry types, I think the new sf2geometry function is the place to add that functionality.