Use esri2sf to get data from an ArcGIS FeatureServer or MapServer for a location
Source:R/get_esri_data.R
get_esri_data.Rd
Wraps the esri2sf::esri2sf()
and esri2sf::esri2df()
functions to download
an ArcGIS FeatureServer or MapServer. Supports spatial filtering with
bounding box based on location and filtering by location name (if location
name column is provided). As of fall 2022, this package suggests the
elipousson/esri2sf fork using
httr2.
Usage
get_esri_data(
url,
location = NULL,
dist = getOption("getdata.dist"),
diag_ratio = getOption("getdata.diag_ratio"),
unit = getOption("getdata.unit"),
asp = getOption("getdata.asp"),
crs = getOption("getdata.crs", 3857),
where = NULL,
name = NULL,
name_col = NULL,
coords = NULL,
from_crs = getOption("getdata.crs", 4326),
clean_names = TRUE,
token = NULL,
progress = TRUE,
quiet = FALSE,
.name_repair = janitor::make_clean_names,
...,
call = caller_env()
)
get_esri_layers(
location = NULL,
layers = NULL,
url = NULL,
nm = NULL,
token = NULL,
clean_names = TRUE,
quiet = FALSE,
.name_repair = janitor::make_clean_names,
...,
call = caller_env()
)
get_esri_metadata(
url,
token = NULL,
meta = NULL,
clean_names = TRUE,
.name_repair = janitor::make_clean_names,
call = caller_env()
)
Arguments
- url
FeatureServer or MapServer url to retrieve data from. Passed to
url
parameter ofesri2sf::esri2sf()
oresri2sf::esri2df()
functions. Forget_esri_layers()
, the optional url must be a service url which is the base url for one or more layer urls.- location
sf
,sfc
, orbbox
object (or other object convertible withas_bbox()
. Optional.- dist
buffer distance in units. Optional.
- diag_ratio
ratio of diagonal distance of area's bounding box used as buffer distance. e.g. if the diagonal distance is 3000 meters and the "diag_ratio = 0.1" a 300 meter will be used. Ignored when
dist
is provided.- unit
Units for buffer. Supported options include "meter", "foot", "kilometer", and "mile", "nautical mile" Common abbreviations (e.g. "km" instead of "kilometer") are also supported. Distance in units is converted to units matching GDAL units for x; defaults to "meter"
- asp
Aspect ratio of width to height as a numeric value (e.g. 0.33) or character (e.g. "1:3"). If numeric,
get_asp()
returns the same value without modification.- crs
Cordinate reference system to return, Default: 4326 for
sf_to_df()
andNULL
fordf_to_sf()
.- where
where query string passed to esri2sf, Default:
NULL
- name, name_col
Name value and name column found in the ArcGIS FeatureServer or MapServer data.
- coords
Coordinate columns for input data.frame or output sf object (if geometry is 'centroid' or 'point') Default: c("lon", "lat").
- from_crs
For
df_to_sf()
, coordinate reference system used by coordinates or well known text in data frame.- clean_names
If
TRUE
, set .name_repair tojanitor::make_clean_names()
Ignored whenget_esri_metadata()
is not returning a data.frame, e.g.meta = "id"
.- token
string for authentication token. defaults to
NULL
.- progress
Show progress bar from
cli::cli_progress_along()
ifTRUE
. DefaultFALSE
.- quiet
If
TRUE
, usesuppressMessages()
to prevent the printing of messages about the requested layer. Defaults toFALSE
.- .name_repair
Passed to
tibble::as_tibble()
.- ...
Arguments passed on to
esri2sf::esri2sf
outFields
vector of fields you want to include. default is
NULL
for all fields.replaceDomainInfo
If
TRUE
, add domain information to the return data frame. DefaultFALSE
.
- call
The execution environment of a currently running function, e.g.
caller_env()
. The function will be mentioned in error messages as the source of the error. See thecall
argument ofabort()
for more information.- layers
Either a vector with URLs, a named list of urls, or a numeric vector; defaults to
NULL
. Optional if url is a- nm
Name or vector of names to add to the layers; defaults to
NULL
.- meta
Name of metadata list value to return from esri2sf::esrimeta, e.g. "name" to return layer name. Defaults to
NULL
.