Load and preview WFS data with Geopandas

A minimal example for loading WFS data into a Geopandas dataframe and displaying its preview on a map.

This particular example requires switching of XY coordinate values in order to display the features correctly, but it may not be the case for your own data.

import geopandas as gpd  
from requests import Request  
import shapely

url = "https://msip.um.krakow.pl/arcgis/services/ZSOZ/EGIB_WFS/MapServer/WFSServer"
epsg="2180"
params = dict(service='WFS', version="1.0.0", request='GetFeature', typeName="EGIB:budynki", outputFormat='GML2')
wfs_request = Request('GET', url, params=params).prepare().url
data = gpd.read_file(wfs_request).set_crs(epsg=epsg, inplace=True, allow_override=True)
data.geometry = data.geometry.map(lambda polygon: shapely.ops.transform(lambda x, y: (y, x), polygon))
data.explore()

Displaying the result requires running the code in a Jupyter notebook.

Result: