Skip to contents

This function retrieves map service layers from an ArcGIS REST services API and returns them as a RasterLayer object

Usage

get_map_layer(
  url,
  sf_object = NULL,
  bbox = NULL,
  token = "",
  clip_raster = TRUE,
  format = "png",
  transparent = TRUE,
  add_legend = TRUE,
  ...
)

Arguments

url

A character string of the url for the layer to pull

sf_object

An sf object used for the bounding box

bbox

Character string of the bounding box

token

A character string of the token (if needed)

clip_raster

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

format

The raster format desired. Default is "png"

transparent

Logical. Retrieve a raster with a transparent background (TRUE, default) or not (FALSE)

add_legend

Logical. Pull legend and match to color values (TRUE, default) or not (FALSE)

...

Additional arguments to pass to the ArcGIS REST API

Value

A "RasterLayer" object

Details

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.

Examples

if (FALSE) {
wi_landcover<- get_map_layer(wi_landcover_url, wis_poly)
plot_layer(wi_landcover, outline_poly = wis_poly)
}