Skip to content

gdal cheatsheet

Alexander Rolek edited this page Sep 7, 2016 · 8 revisions

Reproject a shapefile

ogr2ogr -t_srs EPSG:3857 /path/to/data/out.shp /path/to/data/in.shp

Pipe shapefile into PostGIS

shp2pgsql -D -I -s 3857 in.shp schema.table_name | psql "host={host} port={port} dbname={db_name} user={user}"

Command line explination:

  • -D: use the dump format instead of INSERT. Much faster for large datasets.
  • -I: create geospatial index on the geometry column
  • -s: SRID to reproject the data

Additional Notes

  • encoding can be adjusted from shp2pgsql command by using the -W flag. i.e. -W "latin1"
Clone this wiki locally