diff --git a/DESCRIPTION b/DESCRIPTION index b1a2175..579a8b5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 = "cole.brokamp@gmail.com", diff --git a/NAMESPACE b/NAMESPACE index 959379f..db3dda0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) diff --git a/R/cincy_geographies.R b/R/cincy_geographies.R index 8ac9623..7b1cd98 100644 --- a/R/cincy_geographies.R +++ b/R/cincy_geographies.R @@ -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 diff --git a/man/cincy_addr_geo.Rd b/man/cincy_addr_geo.Rd new file mode 100644 index 0000000..adb5a5a --- /dev/null +++ b/man/cincy_addr_geo.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/cincy_geographies.R +\name{cincy_addr_geo} +\alias{cincy_addr_geo} +\title{Cincy address geographies} +\usage{ +cincy_addr_geo() +} +\value{ +a simple features object with columns \code{cagis_address}, \code{cagis_address_place}, \code{cagis_address_type}, +\code{cagis_s2}, \code{cagis_parcel_id}, \code{cagis_is_condo}, and a geometry column (\code{s2_geography}) +} +\description{ +CAGIS data (see \code{install_cagis_data()}) provides a list of all addresses in Hamilton County. +Addresses are filtered for the following criteria: +\itemize{ +\item use only addresses that have \code{STATUS} of \code{ASSIGNED} or \code{USING} and are not orphaned (\code{ORPHANFLG == "N"}) +\item omit addresses with \code{ADDRTYPE}s that are milemarkers (\code{MM}), parks (\code{PAR}), infrastructure projects (\code{PRJ}), +cell towers (\code{CTW}), vacant or commercial lots (\code{LOT}), and other miscellaneous non-residential addresses (\code{MIS}, \code{RR}, \code{TBA}) +\item s2 cell is derived from LONGITUDE and LATITUDE fields in CAGIS address database +} +} +\examples{ +cincy_addr_geo() +} diff --git a/man/install_cagis_data.Rd b/man/install_cagis_data.Rd index 194453e..05927de 100644 --- a/man/install_cagis_data.Rd +++ b/man/install_cagis_data.Rd @@ -6,7 +6,7 @@ \usage{ install_cagis_data( cagis_data_url = - "https://www.cagis.org/Opendata/Quarterly_GIS_Data/CAGISOpenDataQ4_2024.gdb.zip" + "https://www.cagis.org/Opendata/Quarterly_GIS_Data/CAGISOpenDataQ1_2025.gdb.zip" ) } \arguments{ diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index 5e4c7ee..c54e593 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -43,6 +43,7 @@ reference: - cincy_city_geo - install_cagis_data - cincy_zcta_geo + - cincy_addr_geo - title: CoDEC developer tools contents: - codec_colors diff --git a/tests/testthat/test-cincy_geographies.R b/tests/testthat/test-cincy_geographies.R index 3b1ecf8..ac979fc 100644 --- a/tests/testthat/test-cincy_geographies.R +++ b/tests/testthat/test-cincy_geographies.R @@ -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)) +})