In dit bericht laten we zien hoe jij - als Spatial Data Scientist - R<\/A> kunt gebruiken om toegang te krijgen tot een ArcGIS REST Service, door de volgende vraag te beantwoorden: "Zijn er verlaten spoorwegen in Florida?<\/EM>".<\/P><\/P>De ArcGIS Living Atlas of the World<\/A> biedt een mooie dataset met spoorwegen in de Verenigde Staten: USA Railroads<\/A>. Via de Service URL komen we op de querypagina van deze Feature Layer<\/A>.<\/P><\/P>Het onderstaande R-script laat zien hoe je snel een interactieve kaart kunt maken om onze vraag te beantwoorden. Scroll naar beneden voor een korte uitleg...<\/P>library
<\/P>
Het onderstaande R-script laat zien hoe je snel een interactieve kaart kunt maken om onze vraag te beantwoorden. Scroll naar beneden voor een korte uitleg...<\/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?
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.