arcgislayers
arcgislayers copied to clipboard
Support /getSamples endpoint for image servers
Documentation: https://developers.arcgis.com/rest/services-reference/enterprise/get-samples.htm Work against landsat: https://landsat2.arcgis.com/arcgis/rest/services/Landsat/MS/ImageServer/getSamples
#' Get Samples from Image Service
#'
get_samples <- function(
x,
geometry,
interpolation = c("bilinear", "cubic", "majority", "nearestneighbor")
fields = NULL,
sample_distance = NULL,
sample_count = NULL,
mosaic_rule = NULL,
slice_id = NULL
) {
# verify it is an image server
check_inherits_any(x, "ImageServer")
# mosaic rules:
# https://developers.arcgis.com/rest/services-reference/enterprise/mosaic-rules.htm
# interpolation values
# RSP_BilinearInterpolation | RSP_CubicConvolution | RSP_Majority | RSP_NearestNeighbor
# TODO handle fields
# prepare geometry for adding to the request.
# we will use prepare_spatial_filter()
# but the predicate is irrelevant here we will extract
# only the geometryType and the geometry
geom_prepped <- prepare_spatial_filter(geometry, predicate = "intersects")
b_req <- httr2::req_url_path_append(
httr2::request(x[["url"]]),
"getSamples"
)
resp <- httr2::req_body_form(
b_req,
geometryType = geom_prepped[["geometryType"]],
geometry = geom_prepped[["geometry"]],
outFields = "*",
f = "json"
)
}