Skip to content

Instantly share code, notes, and snippets.

Created Mar 4, 2018
What would you like to do?
Extract population from NC VTD data.

I started with some tract level data:

ogr2ogr census_features Census_Features.gdb

There is a good data dictionary on the site at well, where I found that the total population is PL10AA_TOT:

Manual for GDAL to convert to csv:

# Compute the centroid for each tract, and force lat/long geometric projection:
ogr2ogr -sql 'select ST_Centroid(geometry) as center,* from Tract' -t_srs crs:84 -dialect sqlite tract_centroid.shp Tract.shp

# Create a CSV with the lat/long, and total population.
ogr2ogr -f CSV -sql 'select PL10AA_TOT from tract_centroid' tract.csv tract_centroid.shp -lco GEOMETRY=AS_XY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment