Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support /getSamples endpoint for image servers #115

Open
JosiahParry opened this issue Dec 7, 2023 · 0 comments
Open

Support /getSamples endpoint for image servers #115

JosiahParry opened this issue Dec 7, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@JosiahParry
Copy link
Collaborator

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"
  )
}
@JosiahParry JosiahParry added the enhancement New feature or request label Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant