[gdal-dev] How to convert GDAL Vector dataset to memory stream

MRRAJESH rajeshreddy82 at gmail.com
Sat Jun 20 22:10:54 PDT 2020


Hi Tamas,

Thanks for your suggestions. Will it work for MVT memory dataset?

We have an MVT memory dataset with us. How to convert this to memory stream.

*Example: *
.....
var vsibuf = string.Format(@"/vsimem/mvt");
var newDs = Gdal.wrapper_GDALVectorTranslateDestName(vsibuf, ds1,
gdalOptions, null, null);
newDs.Dispose();

string filePath = string.Format("{0}\\{1}\\{2}\\{3}.mvt", vsibuf, 18, 66027,
96262);

We tried below ways:

*Way1:*
 
Dataset ds = Gdal.OpenEx(filePath, 0, null, open_options, null);
 
How to convert a dataset (ds) to memory stream?
 
*Way2:*
 
var bufPtr = Gdal.VSIFOpenL(filePath, "rb");
        if (bufPtr != null)
        {
          Gdal.VSIFSeekL(bufPtr, 0, 2); // seek to end
          var contentSize = Gdal.VSIFTellL(bufPtr1);
          Gdal.VSIFSeekL(bufPtr1, 0, 0); // seek to beginning 
          var data = new byte[contentSize];
          var content = VSIFReadL(1, contentSize, bufPtr); // This method is
not available in C#.
    }
 
How to get content here?

Regards,
Rajesh



--
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html


More information about the gdal-dev mailing list