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

Tamas Szekeres szekerest at gmail.com
Sun Jun 21 02:24:23 PDT 2020


Hi,

MVT is a vector format, so you should use OGR to manipulate it.
To open the OGR format and iterate the features on a layer refer to the
following c# example:

https://github.com/OSGeo/gdal/blob/master/gdal/swig/csharp/apps/ogrinfo.cs

Also refer to the MVT driver information page, how the connection string
should look like and which open options can be used.

https://gdal.org/drivers/vector/mvt.html

Best regards,

Tamas


MRRAJESH <rajeshreddy82 at gmail.com> ezt írta (időpont: 2020. jún. 21., V,
7:11):

> 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
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20200621/775c9e56/attachment.html>


More information about the gdal-dev mailing list