These helpers provide easy access to the layers contained in a
FeatureServer
or MapServer
.
Usage
get_layer(x, id = NULL, name = NULL, token = arc_token())
get_all_layers(x, token = arc_token())
get_layers(x, id = NULL, name = NULL, token = arc_token())
Arguments
- x
an object of class
FeatureServer
orMapServer
- id
default
NULL
. A numeric vector of unique ID of the layer you want to retrieve. This is a scalar inget_layer()
.- name
default
NULL
. The name associated with the layer you want to retrieve.name
is mutually exclusive withid
. This is a scalar inget_layer()
.- token
your authorization token.
Value
get_layer()
returns a singleFeatureLayer
orTable
based on its IDget_layers()
returns a list of the items specified by theid
orname
argumentget_all_layers()
returns a namedlist
with an elementlayers
andtables
. Each a list containingFeatureLayer
andTable
s respectively.
Details
The id
and name
arguments must match the field values of the respective names as seen in the output of list_items()
Examples
if (FALSE) { # \dontrun{
# FeatureServer
furl <- paste0(
"https://services3.arcgis.com/ZvidGQkLaDJxRSJ2/arcgis/rest/services/",
"PLACES_LocalData_for_BetterHealth/FeatureServer"
)
fserv <- arc_open(furl)
fserv
get_layer(fserv, 0)
get_layers(fserv, name = c("Tracts", "ZCTAs"))
get_all_layers(fserv)
} # }