The German state of Schleswig-Holstein has a geoportal, where they provide a link to their WFS endpoint:
making it possible to access the state's cadastral data. I load some parcels to QGIS canvas using this endpoint, and observe the calls made via the Network Logger:
One of the calls:
6701 GET https://service.gdi-sh.de/SH_INSPIREDOWNLOAD_AI_CP_ALKIS?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=cp:CadastralParcel&COUNT=10000&SRSNAME=urn:ogc:def:crs:EPSG::25832&BBOX=599711.71880523720756173,5915094.58108168374747038,600677.40076130512170494,5916482.59453260432928801,urn:ogc:def:crs:EPSG::25832&NAMESPACES=xmlns(cp,http://inspire.ec.europa.eu/schemas/cp/4.0)&NAMESPACE=xmlns(cp,http://inspire.ec.europa.eu/schemas/cp/4.0)
I am attempting to recreate what QGIS does using GeoPandas: make this call, convert response to Polygons. I try:
import fiona
fiona.supported_drivers["NAS"] = "raw"
import geopandas as gpd
url = "https://service.gdi-sh.de/SH_INSPIREDOWNLOAD_AI_CP_ALKIS?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=cp:CadastralParcel&COUNT=10000&SRSNAME=urn:ogc:def:crs:EPSG::25832&BBOX=599711.71880523720756173,5915094.58108168374747038,600677.40076130512170494,5916482.59453260432928801,urn:ogc:def:crs:EPSG::25832&NAMESPACES=xmlns(cp,http://inspire.ec.europa.eu/schemas/cp/4.0)&NAMESPACE=xmlns(cp,http://inspire.ec.europa.eu/schemas/cp/4.0)"
df = gpd.read_file(url)
The resulting dataframe df
does not however contain POLYGON
s, only POINT
s:
I can download the response manually:
URL="https://service.gdi-sh.de/SH_INSPIREDOWNLOAD_AI_CP_ALKIS?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=cp:CadastralParcel&COUNT=10000&SRSNAME=urn:ogc:def:crs:EPSG::25832&BBOX=599711.71880523720756173,5915094.58108168374747038,600677.40076130512170494,5916482.59453260432928801,urn:ogc:def:crs:EPSG::25832&NAMESPACES=xmlns(cp,http://inspire.ec.europa.eu/schemas/cp/4.0)&NAMESPACE=xmlns(cp,http://inspire.ec.europa.eu/schemas/cp/4.0)"
curl $URL -o inspire.xml
How can I make GeoPandas load the parcel polygons, instead of the reference points, into the dataframe?
This is a similar question, where the accepted answer relies on ogrinfo
. I try ogrinfo inspire.xml
, get:
ERROR 1: No schema information loaded
INFO: Open of `inspire.xml'
using driver `NAS' successful.
1: CadastralParcel (Point)
2: ALKIS_beziehungen (None)
i.e. even ogrinfo
does not seem to see the Polygons. They are clearly there (see screenshot of XML in browser above), but something is wrong with the schema, I believe.
Apparently this does not happen for everyone, as pointed out in this answer. In my environment, fiona.__version__
returns 1.8.21
, gpd.__version__
returns 0.11.1
.
Tried the same code in Google Colab (after a !pip3 install geopandas
), it works. There, fiona.__version__
returns 1.8.22
, gpd.__version__
returns 0.12.2
.
Most probably my problem is due to old GeoPandas or Fiona packages.