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

library(AOI)
library(sf)

AOI

DOI R CMD Check Dependencies License: MIT codecov

AOI helps create reproducible, programmatic boundaries for analysis and mapping workflows. The package targets five main use cases:

1. Term based geocoding

AOI uses tidygeocoder as a backend for term-based geooding and Wikipedia APIs. If you have more ridgid addresses tidygeocoder is great!

Foward (from name to location)

Places

geocode(c('Colorado State University', "University of Colorado", 'NOAA'))

Addresses

# Address with POINT representation
geocode('500 Linden St, Fort Collins, CO 80524', pt = TRUE) 

Events

# Single events
geocode(event = 'D-day')

# Multi-location events with BBOX
(harvey = geocode(event = 'Hurricane Harvey', bb = TRUE))

mapview::mapview(harvey)

Reverse (from location to term)

geocode_rev(c(37, -119))

2. Consistent queries for domestic (USA) and international boundaries:

State / Multi-state

aoi_get(state = c("CO", "UT"))

USA Counties

aoi_get(state = "TX", county = "Harris")

World Countries

aoi_get(country = "Ukraine")

USA and World Regions

World_asia = aoi_get(country = "Asia")
aoi_describe(World_asia)


USA_south = aoi_get(state = "south")
aoi_describe(USA_south)

3. Creating flexible AOIs from locations and bounding dimensions.

Place Name and diminsions

# 100 square mile region around Longs Peaks
aoi_ext("Long Peaks", wh = 10)

Location and Diminsions

# 200 square mile region around 37,-119
aoi_ext(xy = c(x = 119, y = 37), wh =  c(20, 10))

Event and Diminsions

# 10,000 square meter region around Normandy Landings
aoi_ext(geo = "white house", wh = 10000, bbox = TRUE) |> 
  st_as_sf() |>
  aoi_map(returnMap = T)

4. View and Draw

NOTE: The following functions require leaflet, shiny and leaflelt.extras. Since these are Suggested Dependencies you will need to install them yourself in warnings appear.

Sometimes it is useful to view the created AOIs. aoi_map offers a quickly formatted leaflet map (not all that dissimilar from mapview so this may retire).

AOI = geocode(geo = c("Paris", "Amsterdam", "Prague", "England"), pt = TRUE) 
aoi_map(AOI, returnMap = TRUE)

Alternatively sometimes users need very specific AOIs that are not POINTs, bounding boxes, or fiat boundaries. For this AOI provides aoi_draw() which allows users to interactively draw an Area of Interest (AOI) using a shiny app. Once an object is drawn and the "Save AOI" button pressed, a new sf object called 'aoi' will appear in your environment.

aoi_draw()
knitr::include_graphics('man/figures/shiny-app.png')

5. Programmatic way to interface with other R packages that require user defined AOIs or bounding boxes

The need for AOI's is rampant in the r-spatial community. AOI plays nicely with the following non-exhaustive list helping users be to the meat of their utilities without getting hung up on boundary definition.

| package | |---| | ggmap |
| nhdplusTools |
| elevatr |
| terrainr | | climateR |
| dataRetrivial |
| soilDB |
| nwmTools |
| FedData |
| hereR |

Please add more!

Installation:

remotes::install_github("mikejohnson51/AOI")

Support:

AOI has been supported with funds from the UCAR COMET program (2018-2019) and the NSF Convergence Accelerator Project (2020).



mikejohnson51/AOI documentation built on Nov. 22, 2023, 6:05 p.m.