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.1.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

census_pgeoloader-0.1.1-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.1.tar.gz.

File metadata

File hashes

Hashes for census_pgeoloader-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2ff87cc2bdc7b46ae97bace63497bdcda3409bbe9e53c631fb9ba7846769b2f3
MD5 2f1537dcf7b1bc5783a89a25ac58d1e8
BLAKE2b-256 4b00717d6cc1726796ffe73cb52f470ef540a825e8df14c561a700bcc4ae1e16

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for census_pgeoloader-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 489b8667f8094ad2fc36ef894e5d6edb049c59e3c0c5d5b5d9ed05815646963a
MD5 3c193b0f7fb5b691fe20f929bc5894fd
BLAKE2b-256 18868362c212708fed8a92343086cb77873657a8ed93cf1592d616edbe7d6f00

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