esri2sf: Import data from ESRI's ArcGIS Server

View source: R/esri2sf.R

esri2sfR Documentation

Import data from ESRI's ArcGIS Server

Description

These functions are the interface to the user.

Usage

esri2sf(
  url,
  outFields = c("*"),
  where = "1=1",
  bbox = NULL,
  token = "",
  geomType = NULL,
  crs = 4326,
  progress = FALSE,
  replaceDomainInfo = TRUE,
  ...
)

esri2df(
  url,
  outFields = c("*"),
  where = "1=1",
  token = "",
  progress = FALSE,
  replaceDomainInfo = TRUE,
  ...
)

esrimeta(url, token = "", fields = FALSE)

Arguments

url

character string for service url, e.g. https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/.

outFields

vector of fields you want to include. default is '*' for all fields".

where

string for where condition. Default is 1=1 for all rows.

bbox

bbox class object from sf::st_bbox().

token

string for authentication token (if needed).

geomType

string specifying the layer geometry ('esriGeometryPolygon' or 'esriGeometryPoint' or 'esriGeometryPolyline' - if NULL, will try to be inferred from the server)

crs

coordinate reference system (see sf::st_sf()). Should either be NULL or a CRS that can be handled by GDAL through sf::st_sf(). Default is 4326. NULL returns the feature in the same CRS that the layer is hosted as in the Feature/Map Server.

progress

Show progress bar with pbapply::pblapply() if TRUE. Default FALSE.

replaceDomainInfo

add domain information to the return dataframe? Default TRUE.

...

additional named parameters to pass to the query. ex) "resultRecordCount = 3"

fields

esrimeta returns dataframe with fields if TRUE. Default FALSE.

Value

sf dataframe (esri2sf) or tibble dataframe (esri2df) or list or dataframe (esrimeta).

Functions

  • esri2sf: Retrieve spatial object

  • esri2df: Retrieve table object (no spatial data).

  • esrimeta: Retrieve layer metadata

Note

When accessing services with multiple layers, the layer number must be specified at the end of the service url (e.g., https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/3). #' The list of layers and their respective id numbers can be found by viewing the service's url in a web browser and viewing the "Layers" heading (e.g., https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/#mapLayerList).

Examples

baseURL <- "https://sampleserver1.arcgisonline.com/ArcGIS/rest/"
url <- paste0(baseURL, "services/Demographics/ESRI_Census_USA/MapServer/3")
outFields <- c("POP2007", "POP2000")
where <- "STATE_NAME = 'Michigan'"
df <- esri2sf(url, outFields = outFields, where = where)
plot(df)


yonghah/esri2sf documentation built on June 2, 2022, 8:18 a.m.