0

The German state of Schleswig-Holstein has a geoportal, where they provide a link to their WFS endpoint:

https://service.gdi-sh.de/SH_INSPIREDOWNLOAD_AI_CP_ALKIS?service=WFS&version=2.0.0&request=GetCapabilities

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:

enter image description here

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 POLYGONs, only POINTs:

enter image description here

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

enter image description here

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.

1 Answer 1

1

I don't understand your problem, when I run your script, I get polygons:

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)
print(df.geometry.head())
0    POLYGON ((599690.313 5915268.949, 599721.202 5...
1    POLYGON ((597116.805 5916472.623, 597248.259 5...
2    POLYGON ((600516.724 5915145.596, 600554.597 5...
3    MULTIPOLYGON (((600598.558 5915149.776, 600599...
4    POLYGON ((600510.934 5915180.078, 600512.871 5...
2
  • Oh ok, that's strange. What fiona and geopandas versions are you using? I appended my question to contain version info.
    – zabop
    Dec 31, 2022 at 12:27
  • Apparently, if fiona.__version__ is 1.8.22 and gpd.__version__ is 0.12.2, problem is solved.
    – zabop
    Dec 31, 2022 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.