I am using the ArcGIS REST API to get lidar data in R, and while I know the image server I'm pulling from has two layers, I can't figure out how to choose the one I want. I know there are two layers because I can load them both in QGIS as WCS layers. The one I want has the ID "0" and is a single band raster with the raw elevation data, and the second (ID "1") is a 3 band RGB image of the elevations with a predefined color palette (without the elevation data itself).
When I fetch the data with the R package arcpullr
without specifying anything, I get the wrong layer (with ID of "1"):
library(arcpullr)
# Creating an SF area of interest layer that will be used as bounding box
aoi <-
st_sf(st_as_sfc(st_bbox(c(xmin = -8071116, xmax = -8066084, ymin = 5523883,
ymax = 5528915), crs = st_crs(3857))))
# Extracting a raster corresponding to the `aoi`
endpoint <- "https://maps.vcgi.vermont.gov/arcgis/rest/services/EGC_services/IMG_VCGI_LIDARNDSM_WM_CACHE_v1/ImageServer/"
ndsm <- get_image_layer(url = endpoint, sf_object = aoi)
I tried adding the service layer ID to the url:
endpoint <- "https://maps.vcgi.vermont.gov/arcgis/rest/services/EGC_services/IMG_VCGI_LIDARNDSM_WM_CACHE_v1/ImageServer/0/"
but I get the error, Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘extent’ for signature ‘"NULL"’.
And I have tried adding the layer as an argument to get_image_layer()
like so:
ndsm <- get_image_layer(url = endpoint, sf_object = aoi, ID = "0")
but the argument is just ignored and I still get back the wrong layer.
I can't find any information about the separate layers in the service webpage. In QGIS, the one I want, with the ID of "0" is named "x57cab711_bbd5_4ef5_b452_19ce02cd64bfy0.afr", and the other is named "x57cab711_bbd5_4ef5_b452_19ce02cd64bfy0.afr_nDSMcache_PrecipMinMaxStrch_0p5_47_v1".
What am I missing?