srai
srai copied to clipboard
OSMPbfLoader returns data out of the given area
OSMPbfLoader returns data partially out of the given area (not clipped to the area). Maybe consider a mode
parameter to set the correct behaviour or just document the behaviour. Copy the snippet below to see:
from srai.regionalizers import geocode_to_region_gdf
from srai.loaders import OSMPbfLoader
from srai.loaders.osm_loaders.filters import GEOFABRIK_LAYERS
area = geocode_to_region_gdf( "Basel, Switzerland")
area.plot(color="blue")
gdf = OSMPbfLoader().load(area, GEOFABRIK_LAYERS)
gdf.plot(color="black")
Workaround:
gdf.clip(area).plot()
Might be worth looking into other loaders' behaviour
This is actually by design, we just read the features from the OSM and don't alter their geometries at all. Looking at the example from the OSM Pbf Loader, I was clipping those features before plotting by hand.
We might add a parameter to force clipping before returning the data, but this operation alters original geometry of the OSM feature.