arcgislayers icon indicating copy to clipboard operation
arcgislayers copied to clipboard

Support providing IDs only

Open JosiahParry opened this issue 8 months ago • 2 comments

Is your feature request related to a problem? Please describe. The python api supports providing only an item id see (https://developers.arcgis.com/python/guide/download-data/). We require a full URL. Perhaps we can handle both scenarios.

Describe the solution you'd like

arc_open("a04933c045714492bda6886f355416f2") should be able to open the layer listed at https://www.arcgis.com/sharing/rest/content/items/a04933c045714492bda6886f355416f2?f=pjson

library(httr2)
library(arcgislayers)

item_url <- "https://www.arcgis.com/sharing/rest/content/items/342a05f149004bb0ab43eb976682beba?f=json"

req <- request(item_url)
resp <- req_perform(req)
res <- resp_body_json(resp)


paste0(
  "https://services1.arcgis.com/",
  res$orgId,
  "/arcgis/rest/services/",
  res$name,
  "/FeatureServer/0"
) |> 
  URLencode() |>
  arc_open()
#> <FeatureLayer <124 features, 8 fields>>
#> Name: Obesity_2013to2014_CHISNE
#> Geometry Type: esriGeometryPolygon
#> CRS: 2229
#> Capabilities: Query

Created on 2023-12-01 with reprex v2.0.2

Additional context

What about item types that are not a supported service like a flat file?

JosiahParry avatar Dec 01 '23 17:12 JosiahParry