Skip to content

jczaplew/postgis2geojson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PostGIS2GeoJSON

postgis2geojson.py

A simple tool for exporting from a PostGIS table to GeoJSON and TopoJSON. Assumes Python 2.7+, psycopg2, and TopoJSON are already installed and in your PATH.

Adapted from Bryan McBride's excellent PHP implementation.

####Example usage:

To export table boundaries from database gisdata as user user to both GeoJSON and TopoJSON:

python postgis2geojson.py -d gisdata -t boundaries -u user --topojson

or, also specify that the geometry column is the_geom, only fields oid and name should be returned, and the output file should be called boundary_data:

python postgis2geojson.py -d gisdata -t boundaries -u user -p password -g the_geom -f oid name -o boundary_data --topojson

####Arguments:

Name Argument Default value Required Description
Help -h Show friendly help message
Database -d Y Database to use
Host -H localhost Host to connect to
User -U postgres Postgres user to use
Password -p Password for Postgres user
Port -P 5432 Database port
Table -t Y Table to query
Fields -f * Database fields to return, separated by a single space
Geometry -g geom Name of geometry column
Where -w Optional WHERE clause to add to the SQL query
File -o data.geojson Name of output file
Topojson --topojson Creates a TopoJSON file in addtion to a GeoJSON
Pretty print --pretty Pretty print the output

A full list of options is also available via python postgis2geojson.py --help.

About

Extract PostGIS tables as GeoJSON and TopoJSON

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages