Skip to content

Instantly share code, notes, and snippets.

View Elizabethcase's full-sized avatar

Elizabeth Case Elizabethcase

View GitHub Profile
@Elizabethcase
Elizabethcase / notes-about-postgis-and-joining-shapes-carto-fun.md
Created December 6, 2017 20:31 — forked from dannguyen/notes-about-postgis-and-joining-shapes-carto-fun.md
PostGIS example (in Carto, i.e. Postgres) of joining Census tract data to a larger entity (Baltimore Police Dept. Districts) and doing a group count. Solves a classic GIS problem -- the Baltimore Census tract shapefiles have demographic/pop info, but the Baltimore police district shapes do not.

The problem

One shapefile has data -- Census demographics population per census tract. But we want to use another type of shape -- police district boundaries -- and count how many people live within those districts.

This requires using a spatial join to associate all the little shapes (Census tracts) with their containing shape (police district)

The data

The police districts data table, which has only shape data and no population info:

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.