arcpullr
has the capability to query not only vector
(Feature) layers, but also raster layers (both Map and Image service
types). The syntax for these is generally the same as for the
get_layer_by_*
family of functions. Map and Image layers
require a bounding box as part of the query, so both
get_map_layer
and get_image_layer
have
required arguments of a URL and an sf
object. These
functions pull the raster layers provided by the URL and return the
layer as a RasterLayer object from the raster
package.
# WDNR Server
image_server <- "https://dnrmaps.wi.gov/arcgis_image/rest/services/"
# WI Landcover Type URL
landcover_path <- "DW_Land_Cover/EN_Land_Cover2_Lev2/MapServer"
landcover_url <- paste0(image_server, landcover_path)
# WI Leaf-off Aerial Imagery URL
wi_leaf_off_path <- "DW_Image/EN_Image_Basemap_Leaf_Off/ImageServer"
wi_aerial_imagery_url <- paste0(image_server, wi_leaf_off_path)
# the wis_poly polygon is available as an exported object in arcpullr
The get_map_layer
function takes a URL and an sf object.
Since the query for this layer type on an ArcGIS REST Service requires a
bounding box any sf object can be used (i.e. POLYGON, POINT, LINE, etc.)
and a bounding box will be created using the extent of the shape.
The example below pulls Wisconsin landcover types and plots them in a map.
wi_landcover <- get_map_layer(landcover_url, wis_poly)
plot_layer(wi_landcover)
The get_image_layer
function works the same as
get_map_layer
except that it queries from an Image layer.
The easiest way to distinguish a Map layer from an Image layer is by
checking the URL. Those from images will end with “ImageServer” whereas
those from maps will end with “MapServer”. Another way to check is to
look a the “Supported Operations” at the bottom of the actual web page
on the ArcGIS REST Service. It will say either “Export Image” or “Export
Map”.
This example pulls with Wisconsin Leaf-off Aerial Imagery dataset from the Wisconsin Department of Natural Resources.
wi_aerial_imagery <- get_image_layer(wi_aerial_imagery_url, wis_poly)
plot_layer(wi_aerial_imagery)