Home > Linux, PostGIS, PostgreSQL, Shapefiles > Convert Shapefiles to SQL

Convert Shapefiles to SQL

The PostgreSQL /bin folder contains an executable capable to perform the conversion:

shp2pgsql shape_file_name myschema.dbtable_name > output_file.sql

psql -d database_name -f output_file.sql

One command conversion and upload to the PostgreSQL can be done all in one step using UNIX pipes:

shp2pgsql shape_file_name myschema.dbtable_name | psql -d database_name

  1. May 21, 2011 at 3:18 am

    This also works on Windows cmd.exe, surprisingly enough.

  1. No trackbacks yet.

Leave a comment