Code Monkey home page Code Monkey logo

census-cb's Introduction

census-cb

PyPI PyPI - Python Version GitHub License Coverage Report Codacy grade

census-cb is a wrapper for downloading and processing Cartography Boundaries from the US Census Bureau. It stands for Census Cartographic Boundaries; apparently that's confusing (but, like most things, it made sense at the time).

The goal of census-cb is to provide an easy way to get GIS information created by the United States Census Bureau. There's a wide variety of cartographic files availbable for download, such as state and county lines, voting district, Tribal subdivisions, and more!

Entity Information

There are a designated set of entities available for download from the census bureau. Each year of available data has a specific set of available entities, and the shape of these entities may change from year to year. You can find a full list pdf of available entities for download on the US Census Bureau site.

Installation

Install using pip

pip install census-cb

Usage

# import census_cb
from census_cb.census_cb import *

# Create a Boundary File for the desired entity
bf = BoundaryFile(2020, 'us', 'state', '500k')

# Create a processor for downloading and unpacking the data; this processor will return a GeoDataFrame
cbfp = CBFProcessor('gdf')

# Downloads and extracts the Boundary File.
cbfp.process_data(bf)

Examples

Download and display the state boudnaries from the US Census Bureau.

# Create a Boundary File for the US State Lines
state_boundary_file = BoundaryFile(2020, 'us', 'state', '500k')

# Create a processor that returns a GeoDataFrame
cbfp = CBFProcessor('gdf')

# Get the Data
state_lines = cbfp.process_data(state_boundary_file)

# See the Data
state_lines.plot()
state_lines.head()

State Boundaries Plot

geometry STATEFP STATENS AFFGEOID GEOID STUSPS NAME LSAD ALAND AWATER
0 MULTIPOLYGON (((144.64538 13.23627, 144.64716 ... 66 01802705 0400000US66 66 GU Guam 00 543555847 934337453
1 MULTIPOLYGON (((-94.71830 29.72885, -94.71721 ... 48 01779801 0400000US48 48 TX Texas 00 676680588914 18979352230
2 MULTIPOLYGON (((-86.95617 45.35549, -86.95463 ... 55 01779806 0400000US55 55 WI Wisconsin 00 140292246684 29343721650
3 MULTIPOLYGON (((-71.28802 41.64558, -71.28647 ... 44 01219835 0400000US44 44 RI Rhode Island 00 2677759219 1323691129
4 MULTIPOLYGON (((-72.03683 41.24984, -72.03496 ... 36 01779796 0400000US36 36 NY New York 00 122049520861 19256750161

To Do

  • provide some better functionality for editing Entity Information after a BoundaryFile object is declared.

census-cb's People

Contributors

tcramm0nd avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.