Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # copies a geopackage or ESRI FileGDB to a given schema on a postgresql database
- # ./push2db schema_name "PG:dbname=dbname host=host port=port user=user password=password" filename.gpkg
- #
- #./push2db cartwheel "PG:dbname=jpsgis host=localhost port=5432 user=rhys password=rhys" ~/Public/electricgis_nkredsqlentclu.gdb.zip
- SCHEMA=$1
- DB_URL=$2
- FILENM=$3
- SRID=$4
- function pushtodb {
- SCHEMA=$1
- DB_URL="$2"
- FILENM=$3
- INTBL=$4
- ogr2ogr -PROGRESS \
- --config PG_USE_COPY YES \
- -f "Postgresql" "$DB_URL" \
- $FILENM \
- -lco UNLOGGED=YES \
- -lco SCHEMA=$SCHEMA \
- -lco GEOMETRY_NAME=g \
- -lco LAUNDER=NO \
- $INTBL
- }
- echo "***************** Creating schema $1;"
- ogrinfo "$2" -sql "CREATE SCHEMA $1;"
- for i in $( ogrinfo $FILENM \
- | grep '^[0-9]' \
- | sed s/[0-9]//g \
- | sed s/://g \
- | sed s/\\s// \
- | sed s/\\s.*// \
- | while read litmus; do echo "$litmus"; done ) ;
- do
- echo item: $i;
- pushtodb $1 "$2" $3 $i
- done
Add Comment
Please, Sign In to add comment