Which says I can use the memory file system handler, and the python sample code provided by Even seems easy enough to translate:
# Read /vsimem/output.png
f = gdal.VSIFOpenL('/vsimem/output.png', 'rb')
gdal.VSIFSeekL(f, 0, 2) # seek to end
size = gdal.VSIFTellL(f)
gdal.VSIFSeekL(f, 0, 0) # seek to beginning
data = gdal.VSIFReadL(1, size, f)
However, the C# bindings does not seem to include VSIFReadL, although Maksim Sestic seems to indicate that they are.
Is this an issue with the Nuget-package?
I then tried using C# Marshal.Copy, but this fails:
var bufPtr = Gdal.VSIFOpenL(outputRasterFileName, "rb"); //outputRasterFileName is now "/vsimem/file.tiff"
Gdal.VSIFSeekL(bufPtr, 0, 2); // seek to end
var size = Gdal.VSIFTellL(bufPtr);
Gdal.VSIFSeekL(bufPtr, 0, 0); // seek to beginning
var data = new byte[size];
Marshal.Copy(bufPtr, data, 0, size);
I am by no means a C# expert, but I cannot see any reason this should fail? Given a memory pointer and size, read bytes, right?