Skip to content

Commit

Permalink
aoi_ext refreash
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejohnson51 committed Nov 16, 2023
1 parent a7d54a0 commit f821d49
Show file tree
Hide file tree
Showing 338 changed files with 29,239 additions and 3,179 deletions.
5 changes: 2 additions & 3 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
^.*\.Rproj$
^\.Rproj\.user$
^\.travis\.yml$
docs
tests
_pkgdown.yml
vignettes
cran-checks.md
Documentation.pdf
.Rd2pdf27338
paper
pkgdown
^README.Rmd
.github
^codemeta\.json$
data-raw
.covrignore
codecov.yml
1 change: 1 addition & 0 deletions .covrignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
R/aoi_draw.R
28 changes: 28 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: Test coverage

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: covr

- name: Test coverage
run: covr::codecov()
shell: Rscript {0}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
pkgdown
.DS_Store
paper
inst/doc
38 changes: 27 additions & 11 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,42 @@ Type: Package
Title: Areas of Interest
Version: 0.3.0
Authors@R: c(person(given = "Mike", family = "Johnson", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0002-5288-8350")),
person(given = "Justin", family = "Singh-Mohudpur", role = "rev", email = "[email protected]", comment = c(ORCID = "0000-0002-5233-5799")))
person(given = "Justin", family = "Singh-Mohudpur", role = "ctb", email = "[email protected]", comment = c(ORCID = "0000-0002-5233-5799")))
BugReports: https://github.com/mikejohnson51/AOI/issues
Description: A consistent tool kit for forward and reverse geocoding and defining boundaries for spatial analysis.
Depends:
Depends:
R(>= 3.5.0)
Imports:
rvest,
Imports:
datasets,
dplyr,
fipio,
htmlwidgets,
jsonlite,
sf,
leaflet,
leaflet.extras,
rnaturalearth,
tidygeocoder
Suggests:
testthat,
covr,
rvest,
sf,
shiny,
leaflet,
leaflet.extras
terra,
tidygeocoder,
units
Suggests:
climateR,
distill,
FedData,
gdalio,
knitr,
mapview,
nhdplusTools,
osmdata,
raster,
rmarkdown,
testthat,
zonal
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
URL: https://github.com/mikejohnson51/AOI/
VignetteBuilder: knitr
20 changes: 16 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
# Generated by roxygen2: do not edit by hand

export(alt_page)
export(aoi_buffer)
export(aoi_describe)
export(aoi_draw)
export(aoi_ext)
export(aoi_get)
export(aoi_inside)
export(aoi_map)
export(bbox_coords)
export(bbox_get)
export(discritize)
export(fip_meta)
export(geocode)
export(geocodeAOI)
export(geocode_rev)
export(geocode_wiki)
export(getClip)
export(getFiat)
export(list_states)
importFrom(dplyr,`%>%`)
importFrom(dplyr,any_of)
importFrom(dplyr,contains)
importFrom(dplyr,mutate)
importFrom(dplyr,rename)
importFrom(dplyr,select)
importFrom(fipio,as_fips)
importFrom(fipio,fips_metadata)
importFrom(jsonlite,fromJSON)
Expand All @@ -27,18 +31,26 @@ importFrom(rvest,html_table)
importFrom(rvest,html_text)
importFrom(rvest,read_html)
importFrom(sf,`%>%`)
importFrom(sf,st_area)
importFrom(sf,st_as_sf)
importFrom(sf,st_as_sfc)
importFrom(sf,st_bbox)
importFrom(sf,st_buffer)
importFrom(sf,st_cast)
importFrom(sf,st_crs)
importFrom(sf,st_drop_geometry)
importFrom(sf,st_geometry_type)
importFrom(sf,st_intersection)
importFrom(sf,st_intersects)
importFrom(sf,st_is)
importFrom(sf,st_is_longlat)
importFrom(sf,st_point)
importFrom(sf,st_polygon)
importFrom(sf,st_set_crs)
importFrom(sf,st_sf)
importFrom(sf,st_sfc)
importFrom(sf,st_transform)
importFrom(sf,st_union)
importFrom(tidygeocoder,geo)
importFrom(tidygeocoder,reverse_geo)
importFrom(units,set_units)
27 changes: 25 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
AOI 0.2.0 (2021-03-30)
AOI 0.3.0 (2023-09)
=========================

### NEW FEATURES

* `aoi_draw()` - Interactivly draw an Area of Interest (AOI) using a `shiny` app.
* Change original OpenStreetMap geocoder to `tidygeocoder` due to new restrictions
* Previously, we allowed the following for place based area requests:
- c(GEO, distance, distance) --> POLYGON
- c(lat, lng, distance, distance) --> POLYGON

* We now support:
- c(lat, lng) --> POINT
- c(lat, lng, distance) --> POLYGON

* All of these have been moved from aoi_get to aoi_ext which uses:
- geo
- xy
- wh

* materialize_grid from zonal was moved here and called discritize

* Works with terra not raster objects

AOI 0.2.0 (2021-03)
=========================

### NEW FEATURES

* `aoi_draw()` - Interactively draw an Area of Interest (AOI) using a `shiny` app.
12 changes: 5 additions & 7 deletions R/aoi_describe.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,19 @@
#' nc <- sf::read_sf(fname)
#' aoi_describe(AOI = nc[1, ])
#' }
#' @importFrom sf st_transform st_bbox
#'

aoi_describe = function(AOI){

if(any(sf::st_is(AOI, "POLYGON") | sf::st_is(AOI, "MULTIPOLYGON"))){
tot_area = sum(sf::st_area(AOI)) / 1e6
bb = sf::st_bbox(AOI)
bb_area = sf::st_area(sf::st_as_sfc(bb)) / 1e6
if(any(st_is(AOI, "POLYGON") | st_is(AOI, "MULTIPOLYGON"))){
tot_area = sum(st_area(AOI)) / 1e6
bb = st_bbox(AOI)
bb_area = st_area(st_as_sfc(bb)) / 1e6
coverage_per = 100 * (tot_area / bb_area)
tot_units = nrow(AOI)
geom = "POLYGON"
} else {
tot_area = NULL
bb = sf::st_bbox(AOI)
bb = st_bbox(AOI)
bb_area = NULL
coverage_per = NULL
tot_units = nrow(AOI)
Expand Down
6 changes: 3 additions & 3 deletions R/aoi_draw.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ aoi_draw <- function() {

# store the sf in a reactiveValues
values <- shiny::reactiveValues()
values$sf <- sf::st_sf(sf::st_sfc(crs = 4326))
values$sf <- st_sf(st_sfc(crs = 4326))

# update map with user input
shiny::observeEvent(input$aoi_draw_new_feature, {
Expand All @@ -107,7 +107,7 @@ aoi_draw <- function() {
tmp <- shiny::isolate(
sf::st_as_sf(
sf::st_sf(
geometry = sf::st_sfc(sf::st_polygon(list(coords))),
geometry = st_sfc(st_polygon(list(coords))),
crs = 4326
)
)
Expand All @@ -116,7 +116,7 @@ aoi_draw <- function() {
if (feature_type %in% c("rectangle", "polygon")) {
new_sf <- tmp
} else {
new_sf <- sf::st_cast(tmp, "POINT")
new_sf <- st_cast(tmp, "POINT")
}

shiny::isolate(values$sf <- rbind(values$sf, new_sf))
Expand Down
Loading

0 comments on commit f821d49

Please sign in to comment.