Get data layer names from WFS service URL
Learn how to get the typename (e.g. data layers) which are requested for querying WFS services-

Introduction¶
The WFS (Web Feature Service) from the Urban Data Portal provides access to geospatial vector data—such as flood zones, land use, and industrial facilities—allowing users to query, download, and integrate these datasets into applications and analyses directly via standardized web protocols.
Purpose¶
This code connects to the WFS service from the Saarland Urban Data Portal and retrieves the list of available typeName values (i.e. data layers), which are needed to query specific datasets such as flood zones or industrial facilities.
pip install owslib pyproj
Import Python Packages¶
from owslib.wfs import WebFeatureService
wfs_url: str = (
"https://geoportal.saarland.de/arcgis/services/Internet/Hochwasser_WFS/MapServer/WFSServer?&request=GetCapabilities&VERSION=1.1.0&SERVICE=WFS"
)
Get the different data layers (typename)¶
try:
# Connect to WFS service
wfs = WebFeatureService(wfs_url)
# List all typeName values
print("Available typeName values:")
for typename in wfs.contents:
print(typename)
except Exception as e:
print(f"Error: {e}")