Created
August 15, 2013 14:47
-
-
Save cspanring/6241414 to your computer and use it in GitHub Desktop.
Shapefile to PostGIS batch import bash script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
EPSG_CODE=<EPSG_CODE> | |
DATABASE_NAME=<DATABASE_NAME> | |
DATABASE_SCHEMA=<DATABASE_SCHEMA> | |
DATABASE_USER=<DATABASE_USER> | |
for f in *.shp | |
do | |
shp2pgsql -I -s $EPSG_CODE -d $f $DATABASE_SCHEMA.`basename $f .shp` > `basename $f .shp`.sql | |
done | |
for f in *.sql | |
do | |
psql -d $DATABASE_NAME -f $f | |
psql -c "ALTER TABLE $DATABASE_SCHEMA.`basename $f .sql` OWNER TO $DATABASE_USER" -d $DATABASE_NAME | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment