The nycgeo package contains spatial data files for various geographic and administrative boundaries in New York City as well as tools for working with NYC spatial data. Data is in the sf (simple features) format and includes boundaries for boroughs (counties), public use microdata areas (PUMAs), community districts (CDs), neighborhood tabulation areas (NTAs), census tracts, census blocks, city council districts, school districts, and police precincts.

Additionally, selected demographic, social, and economic estimates from the U.S. Census Bureau American Community Survey can be added to the geographic boundaries in nycgeo, allowing for contextualization and easy choropleth mapping. Finally, nycgeo makes it simple to access a subset of spatial data in a particular geographic area, such as all census tracts in Brooklyn and Queens.

Installation

You can install nycgeo from GitHub with:

To get the most out of nycgeo, you should also install and load the sf package when you use nycgeo. If you haven’t attached sf, you will get this friendly reminder when you load nycgeo:

Depending on your operating system and available libraries, sf can be tricky to install the first time. The sf website is a good place to start if you’re having trouble. If you’re using macOS, this is a good guide to installing the required libraries.

Using nycgeo

To learn how to use nycgeo, check out the examples in the Introduction to nycgeo vignette.

Why nycgeo?

The spatial files contained in the nycgeo package are available on websites such as the New York City Department of City Planning’s Bytes of the Big Apple and the U.S. Census Bureau TIGER/Line® Shapefiles, but this package aims to make accessing the spatial data more convenient. Instead of downloading and converting shapefiles each time you need them, nycgeo provides the files in a consistent format (sf) with added metadata that enable joins with non-spatial data.

Other R packages share some features with nycgeo. In particular, the wonderful tidycensus package can access the Census Bureau’s API and download ACS estimates as well as TIGER/Line® Shapefiles (via tigris).

One difference between the boundaries included here and the TIGER/Line® Shapefiles available through tigris is that these boundaries are clipped to the shoreline, allowing for better mapping of New York City. Additionally, nycgeo contains boundaries for geographic areas that are not available from the Census Bureau. This includes neighborhood tabulation areas (NTAs) and community districts (CDs).

Finally, all spatial data included in the package uses the NAD83 / New York Long Island (ftUS) State Plane projected coordinate system (EPSG 2263), which is the standard projection used by New York City government agencies.