Skip to content
Combine Census blocks into new shapes
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
census_map_consolidator
test_data
.coveragerc
.gitignore
.travis.yml
LICENSE
Makefile
Pipfile
Pipfile.lock
README.md
setup.cfg
setup.py
test.py

README.md

census-map-consolidator

Combine Census blocks into new shapes.

Installation

$ pipenv install census-map-consolidator

Usage

Create a list of Census block GEOIDs. That can be simple like this:

>>> your_block_list = ["060371976001008", "060371976001009"]

Or read in from a file like this:

with open("test_data/dtla.csv"), "r") as f:
    your_block_list = f.read().splitlines()

Import our class.

>>> from census_map_consolidator import BlockConsolidator

Pass in the block list as arguments.

>>> c = BlockConsolidator(*your_block_list)

Consolidate the blocks into a single shape. This can take a minute. Big shapefiles have to be downloaded.

>>> c.consolidate()

Write out the new shape. You can do GeoJSON.

>>> c.write("./your-new-shape.geojson")

Or shapefiles.

>>> c.write("./your-new-shape.shp")

That's it. You can inspect your work however you like. But geojsonio is handy.

$ geojsonio < your-new-shape.geojson

dtla

You can’t perform that action at this time.