Skip to contents

Get a sf object with one or more neighborhoods, Baltimore City Council districts, Maryland Legislative Districts, U.S. Congressional Districts, Baltimore Planning Districts, Baltimore Police Districts, or Community Statistical Areas, park districts, or Census blocks, block groups, or tracts. Area type is required and can be used in combination with area name, area id (not supported by all data sets), or location (as an address or sf object). Name and id are not supported for U.S. Census geogrpahies. Use the location parameter to return any areas of the selected type that intersect with the specified location. get_baltimore_area() has different parameter names (more consistent with getdata::get_location()) and is now recommended over get_area() to avoid a name conflict with the sfext::get_area() function.

Usage

get_area(
  type = c("neighborhood", "council district", "legislative district",
    "congressional district", "planning district", "police district", "csa",
    "park district", "block", "block group", "tract"),
  area_name = NULL,
  area_id = NULL,
  location = NULL,
  union = FALSE,
  area_label = NULL
)

get_baltimore_area(
  type = NULL,
  name = NULL,
  id = NULL,
  location = NULL,
  union = FALSE,
  label = NULL
)

get_neighborhood(name, location = NULL, union = FALSE, ...)

Arguments

type

Required. Area type matching one of the boundary datasets included with mapbaltimore. Supported values include "neighborhood", "council district", "legislative district", "congressional district", "planning district", "police district", "csa", "park district". U.S. Census geographies including "block", "block group", and "tract" are supported when using the location parameter only.

area_name

name or names matching id column in data of selected dataset. Character.

area_id

identifier or identifiers matching id column of selected dataset. Not all supported datasets have an id column and the id may be an integer or character depending on the dataset.

location

Location supports to types of values: an address that can be geocoded using tidygeocoder::geo() or an sf object that intersects with the selected area types. If using an sf object, the CRS for the object must be EPSG:2804.

union

If TRUE and multiple area names are provided, the area geometry is combined with sf::st_union(). Defaults to FALSE.

area_label

Label to use as name for area if union is TRUE or as additional label column if union is FALSE. If union is TRUE and area_label is not provided, the original area names are concatenated into a single string.

name

Passed to area_name by get_baltimore_area()

id

Passed to area_id by get_baltimore_area()

label

Passed to area_label by get_baltimore_area()

...

Additional parameters passed by get_neighborhood() to get_area()

Examples

# Get the Harwood neighborhood by name
get_area(
  type = "neighborhood",
  area_name = "Harwood"
)
#> Simple feature collection with 1 feature and 5 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -8528544 ymin: 4767325 xmax: -8528124 ymax: 4768111
#> Projected CRS: WGS 84 / Pseudo-Mercator
#> # A tibble: 1 × 6
#>   name    type        acres osm_id   wikidata                           geometry
#> * <chr>   <chr>       <dbl> <chr>    <chr>                    <MULTIPOLYGON [m]>
#> 1 Harwood Residential  45.4 12752188 Q5677875 (((-8528312 4768109, -8528373 476…

# Get City Council District 12 and 14 by id
get_area(
  type = "council district",
  area_id = c(12, 14)
)
#> Simple feature collection with 2 features and 2 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -8531474 ymin: 4762774 xmax: -8524245 ymax: 4771257
#> Projected CRS: WGS 84 / Pseudo-Mercator
#>    id                       geometry        name
#> 12 14 MULTIPOLYGON (((-8529441 47... District 14
#> 13 12 MULTIPOLYGON (((-8528127 47... District 12

# Get the east and southeast planning districts and combine them
get_area(
  type = "planning district",
  area_id = c("East", "Southeast"),
  union = TRUE,
  area_label = "East and Southeast Planning Districts"
)
#> Simple feature collection with 1 feature and 2 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -8528420 ymin: 4761329 xmax: -8523353 ymax: 4768769
#> Projected CRS: WGS 84 / Pseudo-Mercator
#> # A tibble: 1 × 3
#>   name                                           label                  geometry
#> * <chr>                                          <chr>             <POLYGON [m]>
#> 1 East Planning District and Southeast Planning… East… ((-8525611 4762323, -852…

# Get legislative district for Walters Art Museum (600 N Charles St)
get_area(
  type = "legislative district",
  location = "600 N Charles St, Baltimore, MD 21201"
)
#> Error in address_to_sf(x, ...): The package "tidygeocoder" is required.

# Get Census tracts for the Edmondson Village neighborhood
get_area(
  type = "tract",
  location = get_area("neighborhood", "Edmondson Village")
)
#> Simple feature collection with 4 features and 8 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -8537644 ymin: 4762456 xmax: -8534916 ymax: 4765683
#> Projected CRS: WGS 84 / Pseudo-Mercator
#>   tractce       geoid    name             namelsad   aland awater    intptlat
#> 1  280402 24510280402 2804.02 Census Tract 2804.02  561712      0 +39.2992263
#> 2  160801 24510160801 1608.01 Census Tract 1608.01  389703      0 +39.2980940
#> 3  160802 24510160802 1608.02 Census Tract 1608.02 1226587      0 +39.3002221
#> 4  200701 24510200701 2007.01 Census Tract 2007.01 1203683      0 +39.2900137
#>       intptlon                       geometry
#> 1 -076.6903724 MULTIPOLYGON (((-8537644 47...
#> 2 -076.6840558 MULTIPOLYGON (((-8536821 47...
#> 3 -076.6796308 MULTIPOLYGON (((-8537036 47...
#> 4 -076.6807033 MULTIPOLYGON (((-8537028 47...