Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@
index.md
justfile
^vignettes/articles$
^assets$
^data-raw$
15 changes: 13 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: codec
Title: Community Data Explorer for Cincinnati
Version: 3.0.0
Version: 3.1.0.9000
Authors@R: c(
person("Cole", "Brokamp",
email = "cole.brokamp@gmail.com",
Expand All @@ -16,19 +16,30 @@ Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
Suggests:
base64enc,
bslib,
crosstalk,
testthat (>= 3.0.0),
DT,
devtools,
htmltools,
leaflet,
markdown,
plotly,
roxygen2,
rmarkdown,
dpkg,
knitr
knitr,
shiny,
writexl
Config/testthat/edition: 3
URL: https://geomarker.io/codec
BugReports: https://github.com/geomarker-io/codec/issues
Imports:
rlang,
tidyselect,
stringr,
scales,
glue,
here,
pins,
Expand Down
17 changes: 12 additions & 5 deletions R/CoDEC-package.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
#' About the CoDEC package
#'
#' @description
#' The CoDEC data package specifications provide a set of patterns designed to make sharing tabular community-level data easier.
#' Examples of this type of data include the pediatric hospitalization rate per month per census tract, the total number of gunshots per season per neighborhood, and the housing code enforcement density per year per ZIP code.
#' The CoDEC data package specifications provide a set of patterns designed
#' to make sharing tabular community-level data easier.
#'
#' Data is specified as average values or total counts for census tract geographies during a specific year (or year and month).
#' The required **census tract identifer** and **year** (or *year* and *month*)
#' columns in a CoDEC table contain the spatiotemporal information that can be used to link other data.
#' Examples of this type of data include the pediatric hospitalization rate
#' per month per census tract, the total number of gunshots per season per
#' neighborhood, and the housing code enforcement density per year per ZIP
#' code.
#'
#' Data is specified as average values or total counts for census tract
#' geographies during a specific year (or year and month).
#' The required **census tract identifer** and **year** (or *year* and
#' *month*) columns in a CoDEC table contain the spatiotemporal information
#' that can be used to link other data.
#'
#' @keywords internal
"_PACKAGE"
Expand Down
99 changes: 55 additions & 44 deletions R/cincy_geographies.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@ tiger_download <- function(x) {
#' Cincy census tracts and block groups
#'
#' Read tract and block group ("bg") geographies from the online Census
#' [TIGER/Line](https://www.census.gov/geographies/mapping-files/time-series/geo/tiger-line-file.html)
#' files into R
#' TIGER/Line files into R.
#' @param geography which type of cincy census geography to return
#' @param vintage a character vector of a year corresponding to the vintage of TIGER/Line data
#' @param packaged logical; use the data included with the package instead of (down)loading
#' from the source data?
#' @param vintage a character vector of a year corresponding to the
#' vintage of TIGER/Line data
#' @param packaged logical; use the data included with the package instead
#' of (down)loading from the source data?
#' @details
#' Compressed shapefiles are downloaded from TIGER into an R user data directory and will be cached
#' for use across other R sessions (see `?dpkg::stow` for more details).
#' @returns a simple features object with a geographic identifier column (`geoid`)
#' and a geometry column (`s2_geography`)
#' Compressed shapefiles are downloaded from TIGER into an R user data
#' directory and will be cached for use across other R sessions (see
#' `?dpkg::stow` for more details).
#' @returns a simple features object with a geographic identifier column
#' (`geoid`) and a geometry column (`s2_geography`)
#' @export
#' @examples
#' cincy_census_geo("tract", "2020")
Expand Down Expand Up @@ -68,13 +69,13 @@ cincy_census_geo <- function(
#' This installs the CAGIS Open Data GIS database (`.gdb`) into the data
#' directory for the codec package. Once downloaded, it will be reused
#' across R sessions on the same computer.
#' The geodatabase contains many
#' [layers](https://www.cagis.org/Opendata/Quarterly_GIS_Data/OpenData_Layer_List.txt) that are
#' updated quarterly. (Historical geodatabases are not available here.)
#' @seealso This function is called by `cincy_neighborhood_geo()`, `cincy_city_geo()`
#' and others that import individual layers.
#' @param cagis_data_url the url to the CAGIS Open Data .gdb.zip file; this changes quarterly, so
#' [check](https://www.cagis.org/Opendata/Quarterly_GIS_Data) for something more recent if the file cannot be found
#' The geodatabase contains many layers that are updated quarterly.
#' Historical geodatabases are not available here.
#' @seealso This function is called by `cincy_neighborhood_geo()` and
#' `cincy_city_geo()`, plus other functions that import individual layers.
#' @param cagis_data_url the url to the CAGIS Open Data .gdb.zip file; this
#' changes quarterly, so check the CAGIS Open Data page for something more
#' recent if the file cannot be found.
#' @export
#' @examples
#' \dontrun{
Expand All @@ -101,21 +102,31 @@ install_cagis_data <- function(

#' Cincy address geographies
#'
#' CAGIS data (see `install_cagis_data()`) provides a list of all addresses in Hamilton County.
#' The s2 cell is derived from LONGITUDE and LATITUDE fields in CAGIS address database.
#' CAGIS data (see `install_cagis_data()`) provides a list of all addresses
#' in Hamilton County.
#' The s2 cell is derived from LONGITUDE and LATITUDE fields in the CAGIS
#' address database.
#' @details
#' This function previously excluded addresses with type milemarker (`MM`), park (`PAR`),
#' infrastructure project (`PRJ`), cell tower (`CTW`), vacant or commercial lot (`LOT`),
#' and other miscellaneous non-residential addresses (`MIS`, `RR`, `TBA`).
#' This function previously excluded addresses with type milemarker (`MM`),
#' park (`PAR`), infrastructure project (`PRJ`), cell tower (`CTW`),
#' vacant or commercial lot (`LOT`), and other miscellaneous non-residential
#' addresses (`MIS`, `RR`, `TBA`).
#' Now that they are included, see the examples for how to filter these out.
#' @param packaged logical; use the data included with the package instead of (down)loading
#' from the source data?
#' @return 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`)
#' @param packaged logical; use the data included with the package instead
#' of (down)loading from the source data?
#' @return 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() |>
#' dplyr::filter(!cagis_address_type %in% c("MM", "PAR", "PRJ", "CTW", "LOT", "MIS", "RR", "TBA"))
#' dplyr::filter(
#' !cagis_address_type %in% c(
#' "MM", "PAR", "PRJ", "CTW",
#' "LOT", "MIS", "RR", "TBA"
#' )
#' )
cincy_addr_geo <- function(packaged = TRUE) {
if (packaged) {
out <- get("cincy_addr_geo_2025", asNamespace("codec"), inherits = FALSE) |>
Expand All @@ -142,15 +153,17 @@ cincy_addr_geo <- function(packaged = TRUE) {

#' Cincy neighborhood geographies
#'
#' CAGIS data (see `install_cagis_data()`) provides community council boundaries, but these boundaries can
#' overlap and do not align with census geographies or ZIP codes.
#' By default, the statistical neighborhood approximations are instead returned,
#' which are calculated by aggregating census tracts into 50 matching neighborhoods.
#' CAGIS data (see `install_cagis_data()`) provides community council
#' boundaries, but these boundaries can overlap and do not align with
#' census geographies or ZIP codes.
#' By default, the statistical neighborhood approximations are instead
#' returned, which are calculated by aggregating census tracts into 50
#' matching neighborhoods.
#' @param geography which type of cincy neighborhood geography to return
#' @param packaged logical; use the data included with the package instead of (down)loading
#' from the source data?
#' @returns a simple features object with a geographic identifier column (`geoid`)
#' and a geometry column (`s2_geography`)
#' @param packaged logical; use the data included with the package instead
#' of (down)loading from the source data?
#' @returns a simple features object with a geographic identifier column
#' (`geoid`) and a geometry column (`s2_geography`)
#' @export
#' @examples
#' cincy_neighborhood_geo()
Expand Down Expand Up @@ -196,17 +209,15 @@ cincy_city_geo <- function() {

#' Cincy ZIP Code Tabulation Areas
#'
#' Read [ZIP Code Tabulation Areas
#' (ZCTAs)](https://www.census.gov/programs-surveys/geography/guidance/geo-areas/zctas.html)
#' geographies from the online Census
#' [TIGER/Line](https://www.census.gov/geographies/mapping-files/time-series/geo/tiger-line-file.html)
#' files into R
#' @param vintage a character vector of a year corresponding to the vintage of TIGER/Line data
#' @param packaged logical; use the data included with the package instead of (down)loading
#' from the source data?
#' Read ZIP Code Tabulation Areas (ZCTAs) geographies from the online Census
#' TIGER/Line files into R.
#' @param vintage a character vector of a year corresponding to the
#' vintage of TIGER/Line data
#' @param packaged logical; use the data included with the package instead
#' of (down)loading from the source data?
#' @export
#' @returns a simple features object with a geographic identifier column (`geoid`)
#' and a geometry column (`s2_geography`)
#' @returns a simple features object with a geographic identifier column
#' (`geoid`) and a geometry column (`s2_geography`)
#' @examples
#' cincy_zcta_geo("2020")
cincy_zcta_geo <- function(vintage = as.character(2024:2013), packaged = TRUE) {
Expand Down
7 changes: 5 additions & 2 deletions R/codec_design.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#' CoDEC colors
#' @param n a numeric vector of color numbers or character vector of color names; if NULL returns named vector of available colors
#' @param n a numeric vector of color numbers or character vector of color
#' names; if NULL returns named vector of available colors
#' @export
#' @examples
#' plot(1:8, rep(1, 8), col = codec_colors(1:8),
Expand All @@ -16,6 +17,8 @@ codec_colors <- function(n = NULL) {
"orange" = "#E49865",
"red" = "#C28273"
)
if (!is.null(n)) return(codec_col[n])
if (!is.null(n)) {
return(codec_col[n])
}
return(codec_col)
}
Loading
Loading