In diesem Beitrag zeigen wir, wie Sie - als Spatial Data Scientist - R<\/A> verwenden können, um auf einen ArcGIS REST Service zuzugreifen, indem wir folgende Frage beantworten: "Gibt es verlassene Eisenbahnstrecken in Florida?<\/EM>".<\/P><\/P>Der ArcGIS Living Atlas of the World<\/A> bietet einen schönen Datensatz mit Eisenbahnstrecken in den Vereinigten Staaten: USA Railroads<\/A>. Über die Service-URL gelangen wir zur Abfrageseite dieser Feature-Layer<\/A>.<\/P><\/P>Das untenstehende R-Skript zeigt, wie Sie schnell eine interaktive Karte erstellen können, um unsere Frage zu beantworten. Bitte scrollen Sie nach unten für eine kleine Erklärung...<\/P>library
<\/P>
Das untenstehende R-Skript zeigt, wie Sie schnell eine interaktive Karte erstellen können, um unsere Frage zu beantworten. Bitte scrollen Sie nach unten für eine kleine Erklärung...<\/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?
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registrieren Sie ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.