Skip to content

Instantly share code, notes, and snippets.

@bennylope
Created November 26, 2013 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bennylope/7662274 to your computer and use it in GitHub Desktop.
Save bennylope/7662274 to your computer and use it in GitHub Desktop.
Convert shapefiles to SQL and import into an existing, named PostgreSQL database with PostGIS extention already installed.
for SHAPEFILE in $(find . -name "*.shp")
do
BASENAME=$(basename $SHAPEFILE .shp)
DIRNAME=$(dirname $SHAPEFILE)
SQLFILE="${BASENAME}.sql"
shp2pgsql -W UTF-8 $SHAPEFILE $BASENAME > "${DIRNAME}/${BASENAME}.sql"
psql -d richmond -f "${DIRNAME}/${BASENAME}.sql"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment