Skip to content

Commit edc48de

Browse files
Q12025 cagis update and cincy_addr_geo() (#127)
Co-authored-by: Cole Brokamp <[email protected]>
1 parent 02b083e commit edc48de

7 files changed

+71
-3
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: codec
22
Title: Community Data Explorer for Cincinnati
3-
Version: 2.3.0.9001
3+
Version: 2.3.0.9002
44
Authors@R: c(
55
person("Cole", "Brokamp",
66
email = "[email protected]",

NAMESPACE

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Generated by roxygen2: do not edit by hand
22

33
export(as_codec_dpkg)
4+
export(cincy_addr_geo)
45
export(cincy_census_geo)
56
export(cincy_city_geo)
67
export(cincy_county_geo)

R/cincy_geographies.R

+33-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ cincy_county_geo <- function(vintage = as.character(2024:2013)) {
6969
#' options(timeout = max(2500, getOption("timeout")), download.file.method = "libcurl")
7070
#' install_cagis_data()
7171
#' sf::st_layers(install_cagis_data())$name
72-
install_cagis_data <- function(cagis_data_url = "https://www.cagis.org/Opendata/Quarterly_GIS_Data/CAGISOpenDataQ4_2024.gdb.zip") {
72+
install_cagis_data <- function(cagis_data_url = "https://www.cagis.org/Opendata/Quarterly_GIS_Data/CAGISOpenDataQ1_2025.gdb.zip") {
7373
cagis_gdb_name <- tools::file_path_sans_ext(basename(cagis_data_url))
7474
dest <- file.path(tools::R_user_dir(package = "codec", "data"), cagis_gdb_name)
7575
if (file.exists(dest)) {
@@ -81,6 +81,38 @@ install_cagis_data <- function(cagis_data_url = "https://www.cagis.org/Opendata/
8181
return(dest)
8282
}
8383

84+
#' Cincy address geographies
85+
#'
86+
#' CAGIS data (see `install_cagis_data()`) provides a list of all addresses in Hamilton County.
87+
#' Addresses are filtered for the following criteria:
88+
#' - use only addresses that have `STATUS` of `ASSIGNED` or `USING` and are not orphaned (`ORPHANFLG == "N"`)
89+
#' - omit addresses with `ADDRTYPE`s that are milemarkers (`MM`), parks (`PAR`), infrastructure projects (`PRJ`),
90+
#' cell towers (`CTW`), vacant or commercial lots (`LOT`), and other miscellaneous non-residential addresses (`MIS`, `RR`, `TBA`)
91+
#' - s2 cell is derived from LONGITUDE and LATITUDE fields in CAGIS address database
92+
#' @returns a simple features object with columns `cagis_address`, `cagis_address_place`, `cagis_address_type`,
93+
#' `cagis_s2`, `cagis_parcel_id`, `cagis_is_condo`, and a geometry column (`s2_geography`)
94+
#' @export
95+
#' @examples
96+
#' cincy_addr_geo()
97+
cincy_addr_geo <- function() {
98+
install_cagis_data() |>
99+
sf::st_read(layer = "Addresses") |>
100+
tibble::as_tibble() |>
101+
dplyr::filter(STATUS %in% c("ASSIGNED", "USING")) |>
102+
dplyr::filter(ORPHANFLG == "N") |>
103+
dplyr::filter(!ADDRTYPE %in% c("MM", "PAR", "PRJ", "CTW", "LOT", "MIS", "RR", "TBA")) |>
104+
dplyr::transmute(
105+
cagis_address = FULLMAILADR,
106+
cagis_address_place = BLDGPLACE,
107+
cagis_address_type = ADDRTYPE,
108+
cagis_s2 = s2::as_s2_cell(s2::s2_geog_point(LONGITUDE, LATITUDE)),
109+
cagis_parcel_id = PARCELID,
110+
cagis_is_condo = CONDOFLG %in% c("Y")
111+
) |>
112+
dplyr::mutate(s2_geography = s2::s2_cell_to_lnglat(cagis_s2)) |>
113+
sf::st_as_sf()
114+
}
115+
84116
#' Cincy neighborhood geographies
85117
#'
86118
#' CAGIS data (see `install_cagis_data()`) provides community council boundaries, but these boundaries can

man/cincy_addr_geo.Rd

+25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/install_cagis_data.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkgdown/_pkgdown.yml

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ reference:
4343
- cincy_city_geo
4444
- install_cagis_data
4545
- cincy_zcta_geo
46+
- cincy_addr_geo
4647
- title: CoDEC developer tools
4748
contents:
4849
- codec_colors

tests/testthat/test-cincy_geographies.R

+9
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,12 @@ test_that("cincy neighborhoods", {
8787
expect_s3_class(d$s2_geography, "sfc")
8888
expect_true(is.character(d$geoid))
8989
})
90+
91+
test_that("cincy addresses", {
92+
d <- cincy_addr_geo()
93+
expect_s3_class(d, c("sf", "tbl_df"))
94+
expect_s3_class(d$s2_geography, "sfc")
95+
expect_true(is.character(d$cagis_address))
96+
expect_true(is.character(d$cagis_parcel_id))
97+
expect_true(is.logical(d$cagis_is_condo))
98+
})

0 commit comments

Comments
 (0)