Title: | Areas of Interest |
---|---|
Description: | A consistent tool kit for forward and reverse geocoding and defining boundaries for spatial analysis. |
Authors: | Mike Johnson [aut, cre] , Justin Singh-Mohudpur [ctb] |
Maintainer: | Mike Johnson <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.0 |
Built: | 2024-12-05 00:29:51 UTC |
Source: | https://github.com/mikejohnson51/AOI |
Build Domain
.domain(xy, wh, units = default_units, crs = default_crs, bbox = FALSE)
.domain(xy, wh, units = default_units, crs = default_crs, bbox = FALSE)
xy |
a orign specified as a numeric vector |
wh |
width and height (can be a single number) in units (see units arg) |
units |
units of wh expansion |
crs |
output crs |
bbox |
return bbox object? |
vector or sf object
.geocode
.geocode( geo, pt = FALSE, bbox = FALSE, all = FALSE, method = default_method, crs = default_crs )
.geocode( geo, pt = FALSE, bbox = FALSE, all = FALSE, method = default_method, crs = default_crs )
geo |
|
pt |
|
bbox |
|
all |
|
method |
the geocoding service to be used. See ?tidygeocoder::geocode |
crs |
desired CRS. Defaults to AOI::default_crs |
a data.frame, sf object, or vector
Find linked pages to a wikipedia call
alt_page(loc, pt = FALSE)
alt_page(loc, pt = FALSE)
loc |
a wikipedia structured call |
pt |
|
at minimum a data.frame of lat, long
## Not run: alt_page("Twin_towers") ## End(Not run)
## Not run: alt_page("Twin_towers") ## End(Not run)
Describe a spatial (sf/sp/raster) object in terms of a
reproducible AOI (e.g. aoi_get
) parameters.
aoi_describe(AOI)
aoi_describe(AOI)
AOI |
a spatial object ( |
a data.frame of AOI descriptors
{ fname <- system.file("shape/nc.shp", package = "sf") nc <- sf::read_sf(fname) aoi_describe(AOI = nc[1, ]) }
{ fname <- system.file("shape/nc.shp", package = "sf") nc <- sf::read_sf(fname) aoi_describe(AOI = nc[1, ]) }
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()
aoi_draw()
An sf object called 'aoi'.
## Not run: aoi_draw() ## End(Not run)
## Not run: aoi_draw() ## End(Not run)
Build an extent surrinding by location point (longitude, latitude) based on a width and height.
aoi_ext( geo = NULL, xy = NULL, wh = NULL, units = default_units, crs = default_crs, bbox = FALSE )
aoi_ext( geo = NULL, xy = NULL, wh = NULL, units = default_units, crs = default_crs, bbox = FALSE )
geo |
an origion specificed by a name |
xy |
a orign specified as a numeric vector |
wh |
width and height (can be a single number) in units (see units arg) |
units |
units of wh expansion |
crs |
output crs |
bbox |
return bbox object? |
vector or sf object
Generate a spatial geometry from:
aoi_get( x = NULL, country = NULL, state = NULL, county = NULL, fip = NULL, zipcode = NULL, union = FALSE )
aoi_get( x = NULL, country = NULL, state = NULL, county = NULL, fip = NULL, zipcode = NULL, union = FALSE )
x |
|
country |
|
state |
|
county |
|
fip |
a 2 or 5 digit US fip code |
zipcode |
a US zip code. Will return a centroid. |
union |
|
a sf geometry projected to EPSG:4326.
## Not run: # Get AOI for a country aoi_get(country = "Brazil") # Get AOI defined by a state(s) aoi_get(state = "CA") aoi_get(state = c("CA", "nevada")) # Get AOI defined by all states, or the lower 48 aoi_get(state = "all") aoi_get(state = "conus") # Get AOI defined by state & county pair(s) aoi_get(state = "California", county = "Santa Barbara") aoi_get(state = "CA", county = c("Santa Barbara", "ventura")) # Get AOI defined by state & all counties aoi_get(state = "California", county = "all") ## End(Not run)
## Not run: # Get AOI for a country aoi_get(country = "Brazil") # Get AOI defined by a state(s) aoi_get(state = "CA") aoi_get(state = c("CA", "nevada")) # Get AOI defined by all states, or the lower 48 aoi_get(state = "all") aoi_get(state = "conus") # Get AOI defined by state & county pair(s) aoi_get(state = "California", county = "Santa Barbara") aoi_get(state = "CA", county = c("Santa Barbara", "ventura")) # Get AOI defined by state & all counties aoi_get(state = "California", county = "all") ## End(Not run)
A check to see if one object is inside another
aoi_inside(AOI, obj, total = TRUE)
aoi_inside(AOI, obj, total = TRUE)
AOI |
object 2 |
obj |
object 1 |
total |
boolean.
If |
boolean value
Provides a precanned leaflet layout for checking, and refining AOI queries.
Useful leaflet
tools allow for the marking of points, measuring of
distances, and panning and zooming.
aoi_map(AOI = NULL, returnMap = FALSE)
aoi_map(AOI = NULL, returnMap = FALSE)
AOI |
any spatial object ( |
returnMap |
|
a leaflet
html object
## Not run: ## Generate an empty map: aoi_map() ## Check a defined AOI: AOI <- getAOI(clip = list("UCSB", 10, 10)) aoi_map(AOI) ## Chain to AOI calls: getAOI(clip = list("UCSB", 10, 10)) %>% aoi_map() ## Add layers with standard leaflet functions: r <- getAOI("UCSB") %>% # get AOI HydroData::findNWIS() # get SpatialPointsDataframe of local USGS gages aoi_map(r$AOI) %>% addMarkers(data = r$nwis, popup = r$nwis$site_no) ## Save map for reference: m <- getAOI("Kansas City") %>% aoi_map() htmlwidgets::saveWidget(m, file = paste0(getwd(), "/myMap.html")) ## End(Not run)
## Not run: ## Generate an empty map: aoi_map() ## Check a defined AOI: AOI <- getAOI(clip = list("UCSB", 10, 10)) aoi_map(AOI) ## Chain to AOI calls: getAOI(clip = list("UCSB", 10, 10)) %>% aoi_map() ## Add layers with standard leaflet functions: r <- getAOI("UCSB") %>% # get AOI HydroData::findNWIS() # get SpatialPointsDataframe of local USGS gages aoi_map(r$AOI) %>% addMarkers(data = r$nwis, popup = r$nwis$site_no) ## Save map for reference: m <- getAOI("Kansas City") %>% aoi_map() htmlwidgets::saveWidget(m, file = paste0(getwd(), "/myMap.html")) ## End(Not run)
This function provides a simple wrapper around sf::st_bbox that instead returns a named data.frame containing (xmin, ymin, xmax, ymax)
bbox_coords(x)
bbox_coords(x)
x |
a spatial object (sp/sf/raster) |
a data.frame
Get spatial (sf) representation of bounding box of an input feature type. Input can be data.frame, numeric, character, or spatial (sp/sf/raster). If numeric or character order of inputs should be (xmin, xmax, ymin, ymax)
bbox_get(x)
bbox_get(x)
x |
input feature |
a sf polygon
Check for a package
check_pkg(pkg)
check_pkg(pkg)
pkg |
package name |
An area of interest (AOI) is a geographic extent.
The aim of this package is to help users create these -
turning locations, place names, and political boundaries
into servicable representation for spatial analysis.
The package defaults to EPSG:4326
See the README on github, and the project webpage for examples here.
default_crs
default_crs
An object of class numeric
of length 1.
Materialize Grid from File or inputs
discritize( ext = NULL, dim = default_dim, in_crs = default_crs, out_crs = default_crs, spatrast = FALSE, fillValue = NULL, showWarnings = TRUE )
discritize( ext = NULL, dim = default_dim, in_crs = default_crs, out_crs = default_crs, spatrast = FALSE, fillValue = NULL, showWarnings = TRUE )
ext |
extent (xmin, xmax, ymin, ymax) in some coordinate system |
dim |
dimension (number of columns, number of rows) |
in_crs |
projection of input ext |
out_crs |
projection of output object |
spatrast |
should a SpatRaster object be returned? Default is FALSE |
fillValue |
in spatrast is TRUE, what values should fill the object |
showWarnings |
should warnings be shown? |
list or SpatRaster object
Returns a sf data.frame of fipio data
fip_meta(state, county = NULL)
fip_meta(state, county = NULL)
state |
State names, state abbreviations, or one of the following: "all", "conus", "territories" |
county |
County names or "all" |
sf data.frame
## Not run: fip_meta() ## End(Not run)
## Not run: fip_meta() ## End(Not run)
A wrapper around the tidygeocoding and Wikipedia services. Users can request a data.frame (default), vector (xy = TRUE), point (pt = TRUE), and/or a bounding box (bbox = TRUE) representation of a place/location (geo) or event. One or more can be given at a time.
If a single entitiy is requested, 'geocode' will provide a data.frame of lat/lon values and, if requested, a point object and the derived bounding box of the geo/event.
If multiple entities are requested, the returned objects will be a data.frame with columns for input name-lat-lon; if requested, a POINT object will be returned. Here, the bbox argument will return the minimum bounding box of all place names.
geocode( geo = NULL, event = NULL, pt = FALSE, bbox = FALSE, all = FALSE, xy = FALSE, method = default_method, crs = default_crs )
geocode( geo = NULL, event = NULL, pt = FALSE, bbox = FALSE, all = FALSE, xy = FALSE, method = default_method, crs = default_crs )
geo |
|
event |
|
pt |
|
bbox |
|
all |
|
xy |
|
method |
the geocoding service to be used. See ?tidygeocoder::geocode |
crs |
desired CRS. Defaults to AOI::default_crs |
a data.frame, sf object, or vector
Other geocode:
geocode_rev()
,
geocode_wiki()
## Not run: ## geocode a single locations geocode("UCSB") ## geocode a single location and return a POINT object geocode("UCSB", pt = TRUE) ## geocode a single location and derived bbox of location geocode(location = "UCSB", bbox = TRUE) ## geocode multiple locations geocode(c("UCSB", "Goleta", "Santa Barbara")) ## geocode multiple points and generate a minimum bounding box of all locations and spatial points geocode(c("UCSB", "Goleta", "Santa Barbara"), bbox = T, pt = T) ## End(Not run)
## Not run: ## geocode a single locations geocode("UCSB") ## geocode a single location and return a POINT object geocode("UCSB", pt = TRUE) ## geocode a single location and derived bbox of location geocode(location = "UCSB", bbox = TRUE) ## geocode multiple locations geocode(c("UCSB", "Goleta", "Santa Barbara")) ## geocode multiple points and generate a minimum bounding box of all locations and spatial points geocode(c("UCSB", "Goleta", "Santa Barbara"), bbox = T, pt = T) ## End(Not run)
Describe a location using the ERSI and OSM reverse geocoding web-services. This service provides traditional reverse geocoding (lat/lon to placename) but can also be use to get more information about a place name. xy must contain geographic coordinates!
geocode_rev(xy, pt = FALSE, method = default_method)
geocode_rev(xy, pt = FALSE, method = default_method)
xy |
|
pt |
|
method |
the geocoding service to be used. See ?tidygeocoder::geocode |
a data.frame, sf object, or vector
Other geocode:
geocode_wiki()
,
geocode()
## Not run: geocode_rev(xy = c(38,-115)) ## End(Not run)
## Not run: geocode_rev(xy = c(38,-115)) ## End(Not run)
A wrapper around the Wikipedia API to return geo-coordinates of requested inputs.
geocode_wiki(event = NULL, pt = FALSE)
geocode_wiki(event = NULL, pt = FALSE)
event |
|
pt |
|
a data.frame of lat/lon coordinates
Other geocode:
geocode_rev()
,
geocode()
## Not run: ## geocode an Agency geocode_wiki("NOAA") ## geocode an event geocode_wiki("I have a dream speech") ## geocode a n event geocode_wiki("D day") ## geocode a product geocode_wiki("New York Times") ## geocode an event geocode_wiki("Hurricane Harvey") ## End(Not run)
## Not run: ## geocode an Agency geocode_wiki("NOAA") ## geocode an event geocode_wiki("I have a dream speech") ## geocode a n event geocode_wiki("D day") ## geocode a product geocode_wiki("New York Times") ## geocode an event geocode_wiki("Hurricane Harvey") ## End(Not run)
Returns a data.frame of valid states with abbreviations and regions
list_states()
list_states()
data.frame of states with abbreviation and region
## Not run: list_states() ## End(Not run)
## Not run: list_states() ## End(Not run)
A dataset containing the centriods of USA zipcodes
zipcodes
zipcodes
An object of class data.frame
with 33144 rows and 3 columns.