import geopandas as gpd from osgeo import ogr # Read file into GeoDataFrame data = gpd.read_file("my_shapefile.shp") # Pass the GeoDataFrame into ogr as GeoJson shp = ogr.Open(data.to_json()) # Do your stuff with ogr ...
Here is what the above code is Doing:
1. Read the shapefile into a GeoDataFrame
2. Convert the GeoDataFrame into GeoJson
3. Open the GeoJson with ogr
The GeoJson is a temporary file that is created in memory.