Example to retrieve all WFS Features and store as shapefile with pandas and geopandas.
Setup:
conda create -n wfs_env -c conda-forge
conda activate wfs_env
conda install owslib geopandas requests
First, check capabilities in browser :
- Example: https://geodienste.bfn.de/ogc/wfs/schutzgebiet?REQUEST%3DGetCapabilities&SERVICE%3DWFS&VERSION=2.0.0
or with:
python get_cap.py
Select your layer, check count
.
Edit write_shp.py
, update count=1000
and startIndex=ix*1000
- 1000
is an example, update with the maximum number of items to retrieve per iteration, based on the capabilities.
- optionally adapt the WFS format
format='GML'
(you can also try removing this parameter for automatic matching) Then run:
python write_shp.py
This will loop through all WFS features:
https://geodienste.bfn.de/ogc/wfs/schutzgebiet?service=WFS&version=2.0.0&request=GetFeature&typeName=bfn_sch_Schutzgebiet%3ALandschaftsschutzgebiete&count=1000&startIndex=0
https://geodienste.bfn.de/ogc/wfs/schutzgebiet?service=WFS&version=2.0.0&request=GetFeature&typeName=bfn_sch_Schutzgebiet%3ALandschaftsschutzgebiete&count=1000&startIndex=1000
https://geodienste.bfn.de/ogc/wfs/schutzgebiet?service=WFS&version=2.0.0&request=GetFeature&typeName=bfn_sch_Schutzgebiet%3ALandschaftsschutzgebiete&count=1000&startIndex=2000
https://geodienste.bfn.de/ogc/wfs/schutzgebiet?service=WFS&version=2.0.0&request=GetFeature&typeName=bfn_sch_Schutzgebiet%3ALandschaftsschutzgebiete&count=1000&startIndex=3000
.. and concat df
's and finally store. The CRS
is not modified and should match the WFS layer's projection.
Or run:
write_shp_all.py
This will loop through all layers and retrieve all features and store them in separate shapefiles.