Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
WFS to PostGIS
# 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:
for LAYERNAME in `wget -qO- $BASEURL"&request=GetCapabilities" | xpath -q -e "//FeatureType/Name/text()"` ; do
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

This comment has been minimized.

Copy link

tepepa commented Sep 15, 2014

What if the WFS service needs for an HTTP Authentication?
Is there any option to manage this case?

Thank you


This comment has been minimized.

Copy link

ManuelB commented Oct 22, 2016

@tepepa you can add username and password to the wget command:

wget $BASEURL"&request=GetFeature&typeName="$LAYERNAME"&srsName=EPSG:4326&outputFormat=shape-zip" -O $FILENAME".zip" --user=username --password=password

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.