This function retrieves map service layers from an ArcGIS
REST services API and returns them as a RasterLayer object
get_map_layer(
url,
sf_object = NULL,
bbox = NULL,
bbox_crs = NULL,
token = "",
clip_raster = TRUE,
format = "png",
transparent = TRUE,
add_legend = TRUE,
...
)A "SpatRaster" object
A character string of the url for the layer to pull
An sf object used for the bounding box
Vector of bounding box coordinates
CRS for bbox (required if bbox is used)
A character string of the token (if needed)
Logical. Should the raster be clipped to contain only
the pixels that reside in the sf_object? By default, ArcGIS returns
some overlapping edge pixels. Setting clip_raster to TRUE (default)
will remove these using mask from the raster
package
The raster format desired. Default is "png"
Logical. Retrieve a raster with a transparent background (TRUE, default) or not (FALSE)
Logical. Pull legend and match to color values (TRUE, default) or not (FALSE)
Additional arguments to pass to the ArcGIS REST API
This is one of the core functions of the package. It retrieves map service
layers from an ArcGIS REST API designated by the URL. These layers require a
bounding box to query the map layer, which is either taken from the
sf_object argument or optionally can be passed via the bbox
argument. Either sf_object or bbox are optional, but one of
them must be present.
All of the querying parameters are sent via a POST request to the URL, so
if there are issues with passing additional parameters via ...
first determine how they fit into the POST request and make adjustments as
needed. This syntax can be tricky if you're not used to it.
if (FALSE) {
wi_landcover<- get_map_layer(wi_landcover_url, wis_poly)
plot_layer(wi_landcover, outline_poly = wis_poly)
}
Run the code above in your browser using DataLab