I am having trouble getting raster data in R from the ArcGIS REST API. It is located at the endpoint https://maps.vcgi.vermont.gov/arcgis/rest/services/EGC_service/IMG_VCGI_LIDARNDSM_WM_CACHE_v1/ImageServer and I want to fetch just the data for my area of interest. I can successfully load the data in QGIS as a web coverage service using the url "https://maps.vcgi.vermont.gov/arcgis/services/EGC_services/IMG_VCGI_LIDARNDSM_WM_CACHE_v1/ImageServer/WCSServer", but want something I can turn into a raster layer or raster brick in R.
I would prefer a high-level method and have tried the arcpullr
package, using an sf
polygon object of my area of interest to define the bounding box (aoi
in the code below, which is a simple feature collection with 1 feature and 1 field;
Bounding box: xmin: 499682.2 ymin: 208467.7 xmax: 503271.3 ymax: 212056.7;
Projected CRS: NAD83 / Vermont, 32145). This returns an empty raster brick (all values are NA) in the correct location:
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 have also tried to construct the request myself based on the API reference, using various queries, and have only been able to write empty image files (though the server returns status codes of '200'). Here is an example:
url <- "https://maps.vcgi.vermont.gov/arcgis/rest/services/EGC_services/IMG_VCGI_LIDARNDSM_WM_CACHE_v1/ImageServer/exportImage?f=html&bbox=499682.2,208467.7,503271.3,212056.7&imageSR=32145&bboxSR=32145&format=png"
file = tempfile(fileext = ".png")
httr::GET(url = url, httr::write_disk(file))
I would appreciate any ideas for getting arcpullr
to work, suggestions for other relatively easy approaches, or (as a last resort) resources for learning more about APIs.