Open just a subset of shapefile with VectorSource

I’m using wradlib for zonal statistics. I extract mean rainfall data from a radar image for a polygons (subbasins). Because my shapefile is quite large and not fully covered by the radar image, I would like to just open a subset of the shapefile, (defined by bounding box or shape) to save resources and time (I’m running thousands of cases on a HPC ).
I know that this partial opening of large shapefile is possible with geopandas/fiona (Reading and Writing Files — GeoPandas 0.12.2+0.gefcb367.dirty documentation) but is it also possible with wradlib Vector Source (gdal/ogr)?

wradlib.VectorSource can also take iterables as input: "sequence of source points (shape Nx2) or polygons (shape NxMx2) "

So another option would be to open the subset with geopandas and then convert it somehow to an iterable which is accepted by VectorSource as input.
I played around with this a little bit but I am not sure how exactly I can convert a geopandas Dataframe to the desired input format to create a VectorSource object with it.

Here, finally, my two questions:

  1. Can I open a subset of a large shapefile with VectorSource?
  2. How can I convert a geopandas Dataframe into a "sequence of source points (shape Nx2) or polygons (shape NxMx2) " as input to create a VectorSource object?

Looking forward for your ideas, thanks,

@plvoit Great question and nice to see what VectorSource is used for.

You might check the .geo-property of VectorSource this will just open that file using geopandas. This will not help you for your use case, but just to note it.

There is also the .get_data_by_geom-method, which will use geopandas or GDAL to retrieve data which is inside some geometry.

You can also apply GDAL’s Layer.SetSpatialFilter(geom) directly to the VectorSource .ds, but it would be better to add some method (eg. .clip()) which would clip the VectorSource by bounding box/geometry. It would be great if you open an issue on the wradlib github issue tracker with that request.

Hello @kmuehlbauer,
thank you for your reply. I submitted an issue at github with some more ideas and suggestions.
Thank you!