Skip to main content

Load Census shapefiles into PostGIS

Project description

![POLITICO](https://rawgithub.com/The-Politico/src/master/images/logo/badge.png)

# census_pgeoloader

Command line utility to download Census TIGER/Line shapefiles by state from the U.S. Census Bureau and aggregate them into a single table in a PostGIS-enabled database.

# Requirements

Uses [shp2pgsql](http://www.bostongis.com/pgsql2shp_shp2pgsql_quickguide.bqg). Assumes PostgreSQL + PostGIS.

# To install

```bash
$ pip install census_pgeoloader
```

# To use

Pass a connection URI to your PostgreSQL database as well as the states you'd like to aggregate. This will dowload tract-level shapefiles by default.

```bash
$ pgeoloader postgres://postgres@localhost:5432/database KS MO TX VA ...
```

Valid values for states are FIPS codes, postal abbreviations or names. Pass `+` to collect all states.

# Options

```bash
Options:
-t, --table TEXT Name of table to create in DB. Default is
"census_shapes".
-p, --temp TEXT Directory to download files to. Default is
"./shapefiles"
-y, --year TEXT Year. Default is "2016".
-g, --geo [tract|group|block] Geographic unit. Default is "tract".
-s, --srid TEXT Specify an SRID transform, e.g., "4269:4326".
Default is "4269".
--help Show this message and exit.
```

#### Notes:

- `--table` Drops any existing table by that name in the database.
- `--geo` Can pull tracts, block groups or blocks.
- `--srid` Default SRID should be 4269, but you can specify a transform with this option as available in [shp2pgsql](http://www.bostongis.com/pgsql2shp_shp2pgsql_quickguide.bqg).

©2017 POLITICO


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

census_pgeoloader-0.1.3.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

census_pgeoloader-0.1.3-py2.py3-none-any.whl (6.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file census_pgeoloader-0.1.3.tar.gz.

File metadata

File hashes

Hashes for census_pgeoloader-0.1.3.tar.gz
Algorithm Hash digest
SHA256 40a5a58ab1fea4d2dbb919a35572b428ed15e6174561cc80194cd71b082cd2cc
MD5 c32c7b8ad1d3e8e996c3a8a315f2fc09
BLAKE2b-256 c144de1b95dbb0ed1456bac2fa8a40f702b9d60b7b11d2b0600cb9d9fb496a7d

See more details on using hashes here.

File details

Details for the file census_pgeoloader-0.1.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for census_pgeoloader-0.1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f290b028d9756e560e28062d074994d099bd0c605905ffac0faea07338ed1c9d
MD5 491af19c852673f477731052c8bfef08
BLAKE2b-256 49dedc26983af5009c23b700eb27490ef36f0cd647227ab349904f59dddf04e7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page