https://github.com/datadesk/census-map-consolidator
Combine Census blocks into new shapes
https://github.com/datadesk/census-map-consolidator
census geopandas geospatial-data journalism mapping-la-pipeline maps pandas python
Last synced: 6 months ago
JSON representation
Combine Census blocks into new shapes
- Host: GitHub
- URL: https://github.com/datadesk/census-map-consolidator
- Owner: datadesk
- License: mit
- Created: 2019-03-27T15:02:14.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2023-02-23T19:49:15.000Z (over 2 years ago)
- Last Synced: 2025-03-24T10:21:26.628Z (7 months ago)
- Topics: census, geopandas, geospatial-data, journalism, mapping-la-pipeline, maps, pandas, python
- Language: Python
- Homepage:
- Size: 57.6 MB
- Stars: 31
- Watchers: 7
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# census-map-consolidator
Combine Census blocks into new shapes.
### Installation
```bash
pipenv install census-map-consolidator
```### Usage
Create a list of Census block GEOIDs. That can be simple like this:
```python
your_block_list = ["060371976001008", "060371976001009"]
```Or read in from a file like this:
```python
with open("test_data/dtla.csv", "r") as f:
your_block_list = f.read().splitlines()
```Import our class.
```python
from census_map_consolidator import BlockConsolidator
```Pass in the block list as arguments.
```python
c = BlockConsolidator(*your_block_list)
```Consolidate the blocks into a single shape. This can take a minute. Big shapefiles have to be downloaded.
```python
c.consolidate()
```Write out the new shape. You can do GeoJSON.
```python
c.write("./your-new-shape.geojson")
```Or shapefiles.
```python
c.write("./your-new-shape.shp")
```That's it. You can inspect your work however you like. But [geojsonio](https://github.com/mapbox/geojsonio-cli) is handy.
```bash
geojsonio < your-new-shape.geojson
```## Links
* Issues: [github.com/datadesk/census-map-consolidator/issues](https://github.com/datadesk/census-map-consolidator/issues)
* Packaging: [pypi.python.org/pypi/census-map-consolidator](https://pypi.python.org/pypi/census-map-consolidator)
* Testing: [github.com/datadesk/census-map-consolidator/actions](https://github.com/datadesk/census-map-consolidator/actions)