En esta publicación demostraremos cómo usted, como Científico de Datos Espaciales, puede usar R<\/A> para acceder a un Servicio ArcGIS REST, respondiendo a la siguiente pregunta: "¿Hay ferrocarriles abandonados en Florida?<\/EM>".<\/P><\/P>El ArcGIS Living Atlas of the World<\/A> ofrece un conjunto de datos interesante con ferrocarriles en los Estados Unidos: USA Railroads<\/A>. Siguiendo la URL del Servicio podemos llegar a la página de consulta de esta Capa de Entidades<\/A>.<\/P><\/P>El script en R a continuación muestra cómo puede crear rápidamente un mapa interactivo para responder nuestra pregunta. Por favor, desplácese hacia abajo para una pequeña explicación...<\/P>library
<\/P>
El script en R a continuación muestra cómo puede crear rápidamente un mapa interactivo para responder nuestra pregunta. Por favor, desplácese hacia abajo para una pequeña explicación...<\/P>
library
Hi @Egge-Jan_Pollé,
Thank you for the example. I am not familiar with the URL construction. What if I need to query multiple values of a field. In your example, would that be possible to set where = STATE = 'FL' and 'WA' and 'OR'?
The expression where = STATE = c('FL', 'WA','OR') doesn't work either.
Could you help? Thanks!
Yuan Grund
Hi @Egge-Jan_Pollé
Following the question already asked by @YuanGrund , I have the same doubt, but in outFields, c("Var1", "Var2", "Var3") does not work.
Thank you.
EDITED & SOLVED:
Just use: outFields = "Var1, Var2, Var3"
What if we want to access a private survey of our organization, I tried inputing my credentials ins url$username and url$password, but it didn't worked out at all. Here's my code and my output, censoring my sensible information with "~~~"
library(httr)library(sf)library(tmap)
url <- parse_url("https://services6.arcgis.com/~~~~~~~/arcgis/rest/services")url$path <- paste(url$path,"~~~~~~~~/FeatureServer/0/query",sep = "/")url$username <- '~~~USERNAME~~~'url$password <- '~~~PASSWORD~~~'url$query <- list(where = 'objectid = "*"',outFields = "*",returnGeometry = "true",f = "geojson")request <- build_url(url)test <- st_read(request)
https://services6.arcgis.com/~~~~~~~/arcgis/rest/services/~~~~~~~~/FeatureServer/0/query?where=objectid = "*"&outFields=*&returnGeometry=true&f=geojson";Check connection parameters.
Should I try another library rather than httr?
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.