knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

aarapir

Access ArcGIS online API enpoints with R

Project Status: Concept – Minimal or no implementation has been done yet, or the repository is only intended to be a limited example, demo, or proof-of-concept. CRAN_Status_Badge R build status

aarapir provides an R interface for querying and downloading publically accessible ArcGIS Online feature layers. The primary goal is to provide R users with an easy way to download features from ArcMap Online. I don't not anticipate this to be a full-fledged API to ArcGIS Online and Enterprise. See the ArcGIS Python API for a more robust access to the ArcGIS API. This is super experimental and likely to change. This project is not associated with or supported by ESRI.

Features

Example

Download a point feature layer:

library(aarapir)
## Start with a mapserver url, these typically end in "/MapServer"
## Some examples here: https://sampleserver6.arcgisonline.com/arcgis/rest/services

url <- "https://sampleserver6.arcgisonline.com/arcgis/rest/services/WindTurbines/MapServer"

## This returns a list with information from the Map Service
webserver <- service_info(url)

## We can see what feature layers are available to download
webserver$layers

## This returns a list with information about the feature layer
## id 0
layerinfo <- layer_info(webserver, 0)

## This downloads the entire feature layer and reads it into a
## simple feature dataframe
dat <- layer_download(layerinfo)
dat


## If you want to return only objects from a query:
dat <- layer_download(layerinfo, query = "notes = 'test'")
## note query support might vary by server, but generally standard query functions
## work. more info: https://gisweb.tceq.texas.gov/arcgis/sdk/rest/index.html#/Query_Map_Service_Layer/02ss0000000r000000/
## enter the query in quoted plain text, the function will do the proper URI encoding
dat

experimental

Downloading mosaiced images works. I'm having difficulty finding maps that allow downloading source rasters even though it is supported by the API. This is definately going to change.

url <- "https://landsat2.arcgis.com/arcgis/rest/services/Landsat8_Views/ImageServer"
webserver <- service_info(url)
r1 <- image_download(webserver,
                     size = "800,500",)
r1
raster::plotRGB(r1, r = 4, g = 3, b = 2, stretch = "lin",
                bgalpha = 0)


mps9506/aarapir documentation built on May 12, 2020, 1:07 a.m.