I am trying to load a WFS (address: https://fbinter.stadt-berlin.de/fb/wfs/data/senstadt/s_fb_berlinbtk) into QGIS 3.4 in order to save it as a geopackage. I can connect to the WFS but adding it to my session keeps producing a timeout error message after some of the features have loaded. Other WFS with less features have not caused the same problem. Is there any (possibly quick) way to save a WFS with many features as a geopackage or shapefile?
A quick way for doing it without duplicates would be to do the retrieval manually
As you say gives us 103331 features:
<wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:fis="http://www.berlin.de/broker" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" numberMatched="103331" numberReturned="0" timeStamp="2019-10-09T17:41:10.567" xsi:schemaLocation="http://www.berlin.de/broker https://fbinter.stadt-berlin.de/fb/wfs/data/senstadt/s_fb_berlinbtk?REQUEST=DescribeFeatureType&SERVICE=WFS&VERSION=2.0.0&TYPENAMES=fis:s_fb_berlinbtk http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd http://www.opengis.net/gml/3.2 http://schemas.opengis.net/gml/3.2.1/gml.xsd"/>
Now we can request features incrementally by using the startindex and count paging parameters, like:
for the first 1000 then
for the next 1000...
You can experiment to see how many requests you can fetch per request, 2000 works but is slow...
You could also do this paging automatically with a little Python.
Then open the XML files in QGIS as vector layers, and join/export as required. Some WFS services give shapefile or sqlite outputs, but unfortunately that isn't available here, the default XML output works though.
The basic command for saving the feature type "fis:s_fb_berlinbtk" into GeoPackage "biotypen.gpkg" is
ogr2ogr -f gpkg biotypen.gpkg WFS:https://fbinter.stadt-berlin.de/fb/wfs/data/senstadt/s_fb_berlinbtk? fis:s_fb_berlinbtk
It might be good to increase the default page size of 100 features by adding this parameter to the command:
--config OGR_WFS_PAGE_SIZE 1000
You may want to use some other ogr2ogr parameters as well, like
-nln for defining the layer name that is used in GeoPackage.