I am attempting to use a memory vector to crop a raster using GDAL warp but I get the following error:
ERROR 1: Cannot open <osgeo.ogr.DataSource; proxy of <Swig Object of type 'OGRDataSourceShadow *' at 0x000001AF5FC238A0> >.
My code is as follows:
import ogr, gdal drv = ogr.GetDriverByName("Memory") feature_ds = drv.CreateDataSource("memory_name") feature_layer = feature_ds.CreateLayer("layer",srs ,geom_type=ogr.wkbPolygon) featureDefnHeaders = feature_layer.GetLayerDefn() outFeature = ogr.Feature(featureDefnHeaders) geometry = feature.GetGeometryRef() #This feature is a polygon and comes from another dataset outFeature.SetGeometry(geometry) feature_layer.CreateFeature(outFeature) feature_ds.FlushCache() gdal.Warp(out.tif, in.tif, outputType=gdal.GDT_Float32, cutlineDSName=feature_ds, cropToCutline=True, warpMemoryLimit="5000")
I have tested to make sure the data is all valid, the code runs and produces the results I expect when I make the vector a shapefile. I just need to know if it is actually possible to use memory vectors or not.