The problem: get GeoJSON data from a WFS that uses a projection other than WGS84. This is e.g. true for all geo data in Berlin's FIS-Broker GIS. The data there uses the "Soldner" projection (or EPSG:25833).
- You need to know the URL of the WFS you want to get the data from.
- Consider Baumbestand Berlin - Straßenbäume - Sachdaten zur Karte - [WFS]:
- The URL is https://fbinter.stadt-berlin.de/fb/wfs/data/senstadt/s_wfs_baumbestand.
- The last bit of the URL is also the name of the layer:
s_wfs_baumbestand
. - Knowing this, you can
curl
the contents of the WFS and write the output to a local file using this pattern:
curl --output $(LAYER).xml "https://fbinter.stadt-berlin.de/fb/wfs/data/senstadt/s_wfs_baumbestand?service=wfs&version=2.0.0&request=GetFeature&typeNames=$(LAYER)"
- For our example, this would be:
curl --output s_wfs_baumbestand.xml "https://fbinter.stadt-berlin.de/fb/wfs/data/senstadt/s_wfs_baumbestand?service=wfs&version=2.0.0&request=GetFeature&typeNames=s_wfs_baumbestand"
- (that's quite a lot of data, roughly 350mb)
- I'm using the ogr2ogr tool for this.
ogr2ogr -fieldTypeToString All -f "GeoJSON" s_wfs_baumbestand.geojson -s_srs EPSG:25833 -t_srs WGS84 s_wfs_baumbestand.xml