arcpullr package provides functions for pulling spatial data from an ArcGIS REST API and formatting those layers into
sf objects. These functions provide the basis for querying data housed in a spatial REST API in both a spatial and relational manner.
This function is the core of the package, and allows users to pull data from an ArcGIS REST API
The URL should be a specific layer from an ArcGIS REST API, such as the Wisconsin Dep’t. of Natural Resources Hi-cap well layer, for example.
get_spatial_layer() function will retrieve data from this layer, and format it to an object of class sf (i.e. of the R package sf: Simple Features for R).
This function is also query-able both using both SQL code and ArcGIS’s Query (Feature Service) functionality.
Along with SQL, layers from an ArcGIS REST API may be queried spatially. This is accomplished with the
get_layer_by_* family of functions. These functions are essentially a wrapper around
get_spatial_layer that removes the abstraction of the spatial query syntax query by ArcGIS. These functions require a spatial object of class
sf to be passed to the
geometry argument. To test this out you can also quickly create simple
sf objects using
sf_polygons() to test out the service feature.
Spatial queries can be done with polygons, lines, or points…just use the respective
To query via SQL within the function the field name for the query of interest must be known. For example,
For multiple WHERE clauses there is a helper function to string them together properly. This can be called to the where argument above in place of a text string.
The retrieved layers may be plotted in whatever way you like to plot
sf objects. For quick plots to check if your query worked we’ve included the
plot_layer function, which uses either
ggplot2 (default) to plot the layer or can be switched to base graphics.