Downloads GML files from a WFS 2.0 service in a pseudo-paginated way using bounding boxes and combines them again into one file.
Many WFS services limit how many features a single request may return. wfs-downloader splits a large bounding box into square tiles, downloads each tile with a separate GetFeature request, and then merges all tiles into one GML file.
pip install wfs-downloader # from PyPI
pip install git+https://github.com/codeforberlin/wfs-downloader # directly from GitHub
Create a config.yml specifying your setup, e.g. for all street trees in Berlin:
url: https://gdi.berlin.de/services/wfs/baumbestand
layer: baumbestand:strassenbaeume
bbox:
west: 360000.0
south: 5790000.0
east: 420000.0
north: 5840000.0
size: 10000
outputfile: strassenbaeume.xml
projection: EPSG:25833
tmpdir: tmpwhere:
urlis the URL of the WFS service, without query parameters,layeris the name of the layer (thetypeNamesof the request),bboxis the bounding box for the objects you want to retrieve, in the units ofprojection,sizeis the edge length of a single tile (or page), in the units ofprojection,outputfileis the path of the resulting GML file,projectionis the projection used for the requests and the result, andtmpdiris the directory to store the downloaded tiles. It is created if it does not exist.
The example covers Berlin with 6 × 5 tiles of 10 × 10 km, i.e. 30 requests.
Then run the script with the config.yml as argument:
wfs-downloader config.yml
To only download the tiles, or to only merge tiles that were already downloaded, use:
wfs-downloader config.yml --no-combine
wfs-downloader config.yml --no-download