Skip to content

Commit

Permalink
feat: add police_districts_2023 spatial data
Browse files Browse the repository at this point in the history
  • Loading branch information
elipousson committed Nov 10, 2023
1 parent 6e05751 commit 918f763
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 17 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## New data

* Added `buildings_21stc` (2023-04-28), `main_streets` (2023-10-16), `rec_centers` (2023-10-19), and `neighborhoods_2020` (2023-11-06) spatial data.
* Added `buildings_21stc` (2023-04-28), `main_streets` (2023-10-16), `rec_centers` (2023-10-19), `neighborhoods_2020` (2023-11-06), and `police_districts_2023` (2023-11-10) spatial data.
* Added `baltimore_area_xwalk` (2023-11-06) reference data.

## Updated data
Expand Down
14 changes: 14 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,20 @@
#' @source <https://geodata.baltimorecity.gov/egis/rest/services/Planning/Boundaries/MapServer/7>
"police_districts"

#' Baltimore City Police Districts (2023-Current)
#'
#' Baltimore City Police Districts boundaries updated in 2023.
#'
#' @format A data frame with 9 rows and 4 variables:
#' \describe{
#' \item{`id`}{Police district number}
#' \item{`name`}{Police district name}
#' \item{`name_abb`}{District name abbreviation}
#' \item{`geometry`}{MULTIPOLYGON geometry for district boundary}
#'}
#' @source <https://services1.arcgis.com/UWYHeuuJISiGmgXx/arcgis/rest/services/Police_District/FeatureServer/0>
"police_districts_2023"

#' Community Statistical Areas (2010)
#'
#' Community Statistical Areas (CSAs) are clusters of neighborhoods and are
Expand Down
16 changes: 0 additions & 16 deletions data-raw/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -433,22 +433,6 @@ xwalk_csa2nsa <- rio::import(
usethis::use_data(xwalk_csa2nsa, overwrite = TRUE)


# Import Police District boundaries from
police_districts_path <- "https://geodata.baltimorecity.gov/egis/rest/services/Planning/Boundaries/MapServer/7"

police_districts <- esri2sf::esri2sf(police_districts_path) %>%
sf::st_transform(selected_crs) %>%
sf::st_make_valid() %>%
janitor::clean_names("snake") %>%
dplyr::select(
number = objectid,
name = dist_name,
geometry = geoms
) %>%
dplyr::arrange(number)

usethis::use_data(police_districts, overwrite = TRUE)

# Import Baltimore City Public School 2020-2021 attendance zones from ArcGIS Feature Server layer
bcps_zones_path <- "https://services3.arcgis.com/mbYrzb5fKcXcAMNi/ArcGIS/rest/services/SY2122_Ezones_and_Programs/FeatureServer/15"

Expand Down
39 changes: 39 additions & 0 deletions data-raw/police_districts.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
selected_crs <- 2804

# Import Police District boundaries

# FIXME: This URL previously served the legacy boundaries but has been replaced with the current boundaries
# Locate a new URL for the legacy boundaries so this code can still generate the older police_districts object
police_districts_path <- "https://geodata.baltimorecity.gov/egis/rest/services/Planning/Boundaries/MapServer/7"

police_districts_legacy_source <- esri2sf::esri2sf(police_districts_path, crs = selected_crs)

police_districts_legacy_source %>%
sf::st_make_valid() %>%
janitor::clean_names("snake") %>%
dplyr::select(
number = objectid,
name = dist_name,
geometry = geoms
) %>%
dplyr::arrange(number)

usethis::use_data(police_districts, overwrite = TRUE)

# Alternate URL
# "https://geodata.baltimorecity.gov/egis/rest/services/Planning/Boundaries/MapServer/7"
url <- "https://services1.arcgis.com/UWYHeuuJISiGmgXx/arcgis/rest/services/Police_District/FeatureServer/0"

police_districts_source <- esri2sf::esri2sf(url, crs = selected_crs)

police_districts_2023 <- police_districts_source |>
janitor::clean_names("snake") |>
dplyr::select(
id = district_number,
name = dist_name,
name_abb = dist_abbr,
geometry = geoms
) |>
dplyr::arrange(id)

usethis::use_data(police_districts_2023, overwrite = TRUE)
Binary file added data/police_districts_2023.rda
Binary file not shown.
25 changes: 25 additions & 0 deletions man/police_districts_2023.Rd

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

0 comments on commit 918f763

Please sign in to comment.