Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q12025 cagis update #127

Merged
merged 7 commits into from
Feb 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: codec
Title: Community Data Explorer for Cincinnati
Version: 2.3.0.9001
Version: 2.3.0.9002
Authors@R: c(
person("Cole", "Brokamp",
email = "[email protected]",
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand

export(as_codec_dpkg)
export(cincy_addr_geo)
export(cincy_census_geo)
export(cincy_city_geo)
export(cincy_county_geo)
34 changes: 33 additions & 1 deletion R/cincy_geographies.R
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ cincy_county_geo <- function(vintage = as.character(2024:2013)) {
#' options(timeout = max(2500, getOption("timeout")), download.file.method = "libcurl")
#' install_cagis_data()
#' sf::st_layers(install_cagis_data())$name
install_cagis_data <- function(cagis_data_url = "https://www.cagis.org/Opendata/Quarterly_GIS_Data/CAGISOpenDataQ4_2024.gdb.zip") {
install_cagis_data <- function(cagis_data_url = "https://www.cagis.org/Opendata/Quarterly_GIS_Data/CAGISOpenDataQ1_2025.gdb.zip") {
cagis_gdb_name <- tools::file_path_sans_ext(basename(cagis_data_url))
dest <- file.path(tools::R_user_dir(package = "codec", "data"), cagis_gdb_name)
if (file.exists(dest)) {
@@ -81,6 +81,38 @@ install_cagis_data <- function(cagis_data_url = "https://www.cagis.org/Opendata/
return(dest)
}

#' Cincy address geographies
#'
#' CAGIS data (see `install_cagis_data()`) provides a list of all addresses in Hamilton County.
#' Addresses are filtered for the following criteria:
#' - use only addresses that have `STATUS` of `ASSIGNED` or `USING` and are not orphaned (`ORPHANFLG == "N"`)
#' - omit addresses with `ADDRTYPE`s that are milemarkers (`MM`), parks (`PAR`), infrastructure projects (`PRJ`),
#' cell towers (`CTW`), vacant or commercial lots (`LOT`), and other miscellaneous non-residential addresses (`MIS`, `RR`, `TBA`)
#' - s2 cell is derived from LONGITUDE and LATITUDE fields in CAGIS address database
#' @returns a simple features object with columns `cagis_address`, `cagis_address_place`, `cagis_address_type`,
#' `cagis_s2`, `cagis_parcel_id`, `cagis_is_condo`, and a geometry column (`s2_geography`)
#' @export
#' @examples
#' cincy_addr_geo()
cincy_addr_geo <- function() {
install_cagis_data() |>
sf::st_read(layer = "Addresses") |>
tibble::as_tibble() |>
dplyr::filter(STATUS %in% c("ASSIGNED", "USING")) |>
dplyr::filter(ORPHANFLG == "N") |>
dplyr::filter(!ADDRTYPE %in% c("MM", "PAR", "PRJ", "CTW", "LOT", "MIS", "RR", "TBA")) |>
dplyr::transmute(
cagis_address = FULLMAILADR,
cagis_address_place = BLDGPLACE,
cagis_address_type = ADDRTYPE,
cagis_s2 = s2::as_s2_cell(s2::s2_geog_point(LONGITUDE, LATITUDE)),
cagis_parcel_id = PARCELID,
cagis_is_condo = CONDOFLG %in% c("Y")
) |>
dplyr::mutate(s2_geography = s2::s2_cell_to_lnglat(cagis_s2)) |>
sf::st_as_sf()
}

#' Cincy neighborhood geographies
#'
#' CAGIS data (see `install_cagis_data()`) provides community council boundaries, but these boundaries can
25 changes: 25 additions & 0 deletions man/cincy_addr_geo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/install_cagis_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkgdown/_pkgdown.yml
Original file line number Diff line number Diff line change
@@ -43,6 +43,7 @@ reference:
- cincy_city_geo
- install_cagis_data
- cincy_zcta_geo
- cincy_addr_geo
- title: CoDEC developer tools
contents:
- codec_colors
9 changes: 9 additions & 0 deletions tests/testthat/test-cincy_geographies.R
Original file line number Diff line number Diff line change
@@ -87,3 +87,12 @@ test_that("cincy neighborhoods", {
expect_s3_class(d$s2_geography, "sfc")
expect_true(is.character(d$geoid))
})

test_that("cincy addresses", {
d <- cincy_addr_geo()
expect_s3_class(d, c("sf", "tbl_df"))
expect_s3_class(d$s2_geography, "sfc")
expect_true(is.character(d$cagis_address))
expect_true(is.character(d$cagis_parcel_id))
expect_true(is.logical(d$cagis_is_condo))
})