Identifying NYC Parks with Vehicle Traffic

Research Question

BetaNYC’s Research and Data Assistance Request service received the following request from New Yorkers for Parks:

Hi BetaNYC team! Would you be able to help us with a list of NYC Parks that allow personal vehicles to drive through them, prioritizing parks where pedestrians’ and cyclists’ experience in the park is shaped by vehicles (vs. Central Park transverse example, which is separated from people)? […] Not sure how to go about this except by looking at a map, park by park and would love BetaNYC’s support.

Only two New York City parks have banned vehicle traffic: Central Park in Manhattan and Prospect Park in Brooklyn1. It appears there is no official list of parks that do permit vehicles in parks. A tentative list of parks that do may be derived from the assumption that any park that contains a road segment suitable for vehicle traffic, with the exception of Central Park and Prospect Park, allows vehicle traffic.

Code
# Notebook setup

# Use quarto render to generate a static site in /docs
# Set github pages to deploy from main branch, /docs

# Insure packages are installed by checking required packages against installed packages
reqd_pkgs <- c("flextable",
               "sf",
               "tidyverse",
               "mapgl",
               "htmltools",
               "officer",
               "forcats",
               "socratadata",
               "mapgl",
               "mapview",
               "DBI",
               "RPostgres")

install.packages(
  setdiff(
    reqd_pkgs,
    rownames(installed.packages())
  ),
  repos = "https://cloud.r-project.org"
)

lapply(reqd_pkgs, library, character.only = TRUE) |> 
  invisible()

# If needed, ensure that the Quarto render and RStudio read the same environment vars
readRenviron(".Renviron")

# Start Postgres via Docker, wait for healthcheck
system("docker compose up -d --wait")

# Set up connection from env
con <- dbConnect(RPostgres::Postgres())

# Enable PostGIS
invisible(dbExecute(con, "CREATE EXTENSION IF NOT EXISTS postgis"))

# Get cil_table()
source("cil_table.R")

Available Data

Two data sources can be used to derive the list:

  1. Parks Properties
  2. NYC Street Centerline

Parks Properties

The Parks Properties dataset description carries the caveat:

This dataset identifies property managed partially or solely by NYC Parks. This data has been produced in whole or part using secondary data. Data accuracy is limited by the scale and accuracy of the original sources. Site-specific conditions should be field-verified.

At least two ambiguities are described above. One is the official-unofficial nature of the data. It’s provided to NYC Open Data by the Department of Parks, but it’s comprised of secondary data (at least in part, or maybe in whole – another ambiguity. Does the Department of Parks not know what properties are under their jurisdiction?). The other is that it’s unclear what types of properties are included in the dataset. Are they all parks? A mixture of parks and something else? We can take a look at the unique combinations of class, subcategory, and typecategory:

Code
invisible(
  property_types <- soc_read(
    "https://data.cityofnewyork.us/Recreation/Parks-Properties/enfh-gkve.json",
    query = soc_query(
      select = "distinct class, subcategory, typecategory"
    )
  )
)

cil_table(property_types)

CLASS

SUBCATEGORY

TYPECATEGORY

PARK

Bradhurst Gardens Association

Garden

PARK

Building

Buildings/Institutions

PARK

Building

Community Park

PARK

Building

Garden

PARK

Building

Historic House Park

PARK

Building

Managed Sites

PARK

Cemetery

Cemetery

PARK

Community Garden

Garden

PARK

Concession

Buildings/Institutions

PARK

Concession

Managed Sites

PARK

EXWY

Nature Area

PARK

EXWY

Parkway

PARK

EXWY

Strip

PARK

Facility

Buildings/Institutions

PARK

Facility

Operations

PARK

Facility

Undeveloped

PARK

Fill

Nature Area

PARK

Flagship Park

Buildings/Institutions

PARK

Flagship Park

Community Park

PARK

Flagship Park

Flagship Park

PARK

Flagship Park

Nature Area

PARK

Flagship Park

Neighborhood Park

PARK

Flagship Park

Recreational Field/Courts

PARK

Flagship Park

Triangle/Plaza

PARK

Garden

Buildings/Institutions

PARK

Greenthumb

Buildings/Institutions

PARK

Greenthumb

Garden

PARK

Greenthumb

Neighborhood Park

PARK

Historic House

Historic House Park

PARK

Isle

Nature Area

PARK

JOP

Community Park

PARK

JOP

Jointly Operated Playground

PARK

JOP

Neighborhood Park

PARK

JOP

Playground

PARK

Large Park

Buildings/Institutions

PARK

Large Park

Community Park

PARK

Large Park

Flagship Park

PARK

Large Park

Historic House Park

PARK

Large Park

Jointly Operated Playground

PARK

Large Park

Mall

PARK

Large Park

Managed Sites

PARK

Large Park

Nature Area

PARK

Large Park

Neighborhood Park

PARK

Large Park

Parkway

PARK

Large Park

Recreational Field/Courts

PARK

Large Park

Triangle/Plaza

PARK

Large Park

Waterfront Facility

PARK

Mall

Strip

PARK

Mall

Waterfront Facility

PARK

Maple Street Community Garden

Neighborhood Park

PARK

Museum

Managed Sites

PARK

Neighborhood Park

Buildings/Institutions

PARK

Neighborhood Park

Community Park

PARK

Neighborhood Park

Garden

PARK

Neighborhood Park

Historic House Park

PARK

Neighborhood Park

Nature Area

PARK

Neighborhood Park

Neighborhood Park

PARK

Neighborhood Park

Parkway

PARK

Neighborhood Park

Playground

PARK

Neighborhood Park

Recreational Field/Courts

PARK

Neighborhood Park

Strip

PARK

Neighborhood Park

Triangle/Plaza

PARK

Neighborhood Park

Waterfront Facility

PARK

Neighborhood Plgd

Buildings/Institutions

PARK

Neighborhood Plgd

Community Park

PARK

Neighborhood Plgd

Jointly Operated Playground

PARK

Neighborhood Plgd

Lot

PARK

Neighborhood Plgd

Nature Area

PARK

Neighborhood Plgd

Neighborhood Park

PARK

Neighborhood Plgd

Playground

PARK

Neighborhood Plgd

Recreational Field/Courts

PARK

Neighborhood Plgd

Triangle/Plaza

PARK

Neighborhood Plgd

Undeveloped

PARK

Other

Strip

PARK

Parking Lot

Lot

PARK

Parking Lot

Triangle/Plaza

PARK

Parking Lot

Undeveloped

PARK

Pier

Waterfront Facility

PARK

PKWY

Parkway

PARK

Recreation Center

Buildings/Institutions

PARK

REDEC

Community Park

PARK

REDEC

Triangle/Plaza

PARK

Sitting Area/Triangle/Mall

Cemetery

PARK

Sitting Area/Triangle/Mall

Garden

PARK

Sitting Area/Triangle/Mall

Lot

PARK

Sitting Area/Triangle/Mall

Mall

PARK

Sitting Area/Triangle/Mall

Managed Sites

PARK

Sitting Area/Triangle/Mall

Nature Area

PARK

Sitting Area/Triangle/Mall

Neighborhood Park

PARK

Sitting Area/Triangle/Mall

Parkway

PARK

Sitting Area/Triangle/Mall

Playground

PARK

Sitting Area/Triangle/Mall

Recreational Field/Courts

PARK

Sitting Area/Triangle/Mall

Strip

PARK

Sitting Area/Triangle/Mall

Triangle/Plaza

PARK

Sitting Area/Triangle/Mall

Undeveloped

PARK

Sitting Area/Triangle/Mall

Waterfront Facility

PARK

Stadium

Lot

PARK

STRIP

Parkway

PARK

STRIP

Strip

PARK

STRIP

Undeveloped

PARK

To Be Determined

Garden

PARK

Type 1

Mall

PARK

Type 1

Strip

PARK

Type 1

Triangle/Plaza

PARK

Type 2

Strip

PARK

Type 2

Triangle/Plaza

PARK

Undeveloped

Cemetery

PARK

Undeveloped

Community Park

PARK

Undeveloped

Garden

PARK

Undeveloped

Nature Area

PARK

Undeveloped

Neighborhood Park

PARK

Undeveloped

Parkway

PARK

Undeveloped

Recreational Field/Courts

PARK

Undeveloped

Strip

PARK

Undeveloped

Triangle/Plaza

PARK

Undeveloped

Undeveloped

PARK

Buildings/Institutions

PARK

Cemetery

PARK

Community Park

PARK

Garden

PARK

Historic House Park

PARK

Managed Sites

PARK

Nature Area

PARK

Neighborhood Park

PARK

Operations

PARK

Playground

PARK

Strip

PARK

Triangle/Plaza

PARK

Undeveloped

PARK is the only class of property in the dataset. Based on the combinations of subcategory and typecategory, it may be possible to determine which properties may be excluded from our list of parks, but for now we’ll consider each feature in the dataset to be a park.

NYC Street Centerline

The centerline dataset is described as:

The NYC Street Centerline (CSCL) is a road-bed representation of New York City streets containing address ranges and other information such as traffic directions, road types, segment types.

This brief description implies that this dataset is entirely composed of streets, i.e. surfaces for vehicles to travel. However, taking a look at the rw_type reveals that not to be the case2:

Code
street_types <- property_types <- soc_read(
  "https://data.cityofnewyork.us/City-Government/Centerline/inkn-q76z.json",
  query = soc_query(
    select = "distinct rw_type"
  )
)

street_types <- street_types |> 
  mutate(`Roadway Type` = case_when(
    rw_type == 1 ~ "Street",
    rw_type == 2 ~ "Highway",
    rw_type == 3 ~ "Bridge",
    rw_type == 4 ~ "Tunnel",
    rw_type == 5 ~ "Boardwalk",
    rw_type == 6 ~ "Path/Trail",
    rw_type == 7 ~ "StepStreet",
    rw_type == 8 ~ "Driveway",
    rw_type == 9 ~ "Ramp",
    rw_type == 10 ~ "Alley",
    rw_type == 11 ~ "Unknown",
    rw_type == 12 ~ "Non-Physical Street Segment",
    rw_type == 13 ~ "U Turn",
    rw_type == 14 ~ "Ferry Route",
  ))

street_types |>
  arrange(rw_type) |>
  mutate(rw_type = as.character(rw_type)) |>
  cil_table(widths = c(15, 85),
            unit = "%")

rw_type

Roadway Type

1

Street

2

Highway

3

Bridge

4

Tunnel

5

Boardwalk

6

Path/Trail

7

StepStreet

8

Driveway

9

Ramp

10

Alley

12

Non-Physical Street Segment

13

U Turn

14

Ferry Route

We’ll want to exclude segments where rw_type is 6 to keep paths/trails from counting as a site for vehicular traffic. It’s possible that other roadway types should be excluded, but for now, only Path/Trail will be.

Considerations

One consideration for this analysis are large parks spanning city streets. Take, for example, McCarren Park in Greenpoint, Brooklyn, which is comprised of five separate areas:

Code
mccarren <- soc_read(
  "https://data.cityofnewyork.us/Recreation/Parks-Properties/enfh-gkve.json",
  query = soc_query(
    where = "signname = 'McCarren Park'" 
  )
)

maplibre(
  bounds = mccarren |> st_buffer(dist = 150),
  style = carto_style("positron")
) |> 
  add_line_layer(
    id = "mccarren-park",
    source = mccarren,
    line_color = "#3258a3",
    line_opacity = 0.85,
    line_width = 2
  )

If our consideration of a park that permits vehicle traffic is strict, McCarren Park will not qualify unless there are road segments within any of the separate areas. In order to capture the broader definition used by New Yorkers for Parks of “parks where pedestrians’ and cyclists’ experience in the park is shaped by vehicles”, we can use the convex hull operation, which is analogous to the area enclosed by wrapping a rubber band around multi-part areas:

Code
mcc_ch <- mccarren |> st_drop_geometry()

mcc_ch$geometry <- st_convex_hull(mccarren$multipolygon)

st_geometry(mcc_ch) <- mcc_ch$geometry


maplibre(
  bounds = mccarren |> st_buffer(dist = 150),
  style = carto_style("positron")
) |> 
  add_line_layer(
    id = "mccarren-park",
    source = mcc_ch,
    line_color = "#3258a3",
    line_opacity = 0.85,
    line_width = 2
  )

Care must be taken with this approach, though, as the operation may introduce roads into the resulting area that as an artifact. See above along the southwest border of the park where North 12th Street now falls within the new park area, where it didn’t overlap before.

All to say: This more inclusive definition of park area by necessity introduces false positives into the list. Manual review is required

Methodology

  1. Fetch road segments which are not Path/Trail
  2. Fetch parks properties
  3. Get convex hull of property boundaries to enclose disjoint parks
  4. Use spatial inner join with ST_INTERSECTS spatial predicate to identify parks with intersecting street segments
Code
# Cache data download
centerline <- soc_read(
  "https://data.cityofnewyork.us/City-Government/Centerline/inkn-q76z.json",
  query = soc_query(
    where = "rw_type != 6"
  )
) |> st_make_valid()

parks <- soc_read(
  "https://data.cityofnewyork.us/Recreation/Parks-Properties/enfh-gkve.json"
) |> 
  st_make_valid()

# rename geometry cols
st_geometry(centerline) <- "geom"
st_geometry(parks) <- "geom"
Code
# Transform to state plane (ft), write to db
st_write(st_transform(centerline, 2263), con, "centerline", delete_layer = TRUE, quiet = TRUE)
st_write(st_transform(parks, 2263), con, "parks", delete_layer = TRUE, quiet = TRUE)

invisible(dbExecute(con, "DROP TABLE IF EXISTS parks_ch"))

# Compute convex hulls into new table for fast query (rather than as CTE)
invisible(
  dbExecute(con, "
    CREATE TABLE parks_ch AS
    SELECT gispropnum, signname, ST_ConvexHull(ST_MakeValid(geom)) AS geom
    FROM parks")
)

# Create spatial index
invisible(dbExecute(con, "CREATE INDEX ON parks_ch USING GIST (geom)"))

# Analyze parks table
invisible(dbExecute(con, "ANALYZE parks_ch"))

# Query, write result to R object
parks_with_roads_all <- dbGetQuery(con, "
  SELECT p.gispropnum, p.signname, c.physicalid, c.rw_type
  FROM parks_ch p
  JOIN centerline c ON ST_Intersects(p.geom, c.geom)
  ORDER BY p.gispropnum
")

dbDisconnect(con)

# Filter parks, roads based on query results
park_list <- parks |> 
  filter(gispropnum %in% parks_with_roads_all$gispropnum)

road_list <- centerline |> 
  filter(physicalid %in% parks_with_roads_all$physicalid)

With this approach, 481 of 2,059 NYC parks are found to have overlapping roads. They are displayed below:

Code
maplibre(
  bounds = park_list |> st_buffer(500),
  style = carto_style("positron")
) |>
  add_source(
    id = "parks-src",
    data = select(park_list, gispropnum, signname),  # only the columns the map needs
    tolerance = 0                                    # no simplification at any zoom
  ) |>
  # Transparent fill layer for tooltip 
  add_fill_layer(
    id = "parks-hover",
    source = "parks-src",
    fill_color = "#3258a3",
    fill_opacity = 0,
    tooltip = "signname"
  ) |>
  add_line_layer(
    id = "parks-with-roads",
    source = "parks-src",
    line_color = "#3258a3",
    line_opacity = 0.85
  )

As noted earlier, the approach used to identify roads splitting up multi-part parks necessarily introduces false positives. The list of 481 needs to be manually reviewed.

Consider the case of Hoffman Park in Queens: The convex hull boundary (red) overlaps with the ramps on and off of the Long Island Expressway from Woodhaven Boulevard, whereas the actual boundary (blue) does not:

Code
hoffman_park_original <- parks |> 
  filter(name311 == "Hoffman Park") |> 
  select(gispropnum, name311)

hoffman_park_ch <- hoffman_park_original |> 
  st_drop_geometry()

hoffman_park_ch$geom <- st_convex_hull(hoffman_park_original$geom)

st_geometry(hoffman_park_ch) <- "geom"

# Create output csv, geojson
dir.create("output", showWarnings = FALSE)

segment_counts <- count(parks_with_roads_all, gispropnum, name = "road_segments")

park_list |>
  st_drop_geometry() |>
  select(gispropnum, signname, borough, typecategory, subcategory, acres) |>
  left_join(segment_counts, by = "gispropnum") |>
  arrange(borough, signname) |>
  write_csv("output/parks_with_roads.csv", na = "")

invisible(
  park_list |>
    select(gispropnum, signname, borough, typecategory, subcategory, acres) |>
    left_join(segment_counts, by = "gispropnum") |>
    arrange(borough, signname) |>
    st_write("output/parks_with_roads.geojson",
             delete_dsn = TRUE,
             quiet = TRUE)
)

maplibre(
  bounds = hoffman_park_original |> st_buffer(10),
  style = carto_style("positron")
) |>  
  add_line_layer(
    id = "hoffman-original",
    source = hoffman_park_original,
    line_color = "#3258a3",
    line_opacity = 0.85,
    line_width = 2
  ) |> 
  add_line_layer(
    id = "hoffman-ch",
    source = hoffman_park_ch,
    line_color = "#973835",
    line_opacity = 0.85,
    line_width = 2
  )

Review the tentative list of 481 parks: parks_with_roads.csv

Or download the spatial file here: parks_with_roads.geojson