-
-
Save maning/3791668 to your computer and use it in GitHub Desktop.
WFS to PostGIS
This file contains hidden or 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
# Example of downloading all data from a GeoServer WFS server | |
# and loading it into a PostGIS database. Use with caution | |
# as you could put a lot of load on someone's server if they | |
# host a lot of data which might make them sad. | |
# In response to: http://underdark.wordpress.com/2012/09/26/wfs-to-postgis-in-3-steps/ | |
BASEURL="http://data.wien.gv.at/daten/geoserver/ows?service=WFS&version=1.1.0" | |
for LAYERNAME in `wget -qO- $BASEURL"&request=GetCapabilities" | xpath -q -e "//FeatureType/Name/text()"` ; do | |
PARTS=(${LAYERNAME//:/ }) | |
FILENAME=${PARTS[1]} | |
wget $BASEURL"&request=GetFeature&typeName="$LAYERNAME"&srsName=EPSG:4326&outputFormat=shape-zip" -O $FILENAME".zip" | |
mkdir /tmp/$FILENAME | |
unzip -d /tmp/$FILENAME $FILENAME".zip" | |
shp2pgsql -s 4326 -I -S -c -W LATIN1 "/tmp/"$FILENAME"/"$FILENAME".shp" $FILENAME | psql postgis | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment