[gdal-dev] Problems creating a VSI File on Windows

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[gdal-dev] Problems creating a VSI File on Windows

Roberto Ribeiro
Hello list,

I am trying to create a VSI File on Memory, in a W10 system, but am unsure how to proceed with path style.

> VSIFILE* Mem = VSIFileFromMemBuffer("path", (GByte*) NewImg, (vsi_l_offset) (XSize * YSize), FALSE);
> GDALDataset* DS = (GDALDataset*) GDALOpen("path", GA_ReadOnly);

When doing the traditional Windows backslashes ("\\vsimem\\file.tif") it raises the following error when run: "'\vsimem\file.tif' does not exist in the file system, and is not recognized as a supported dataset name."

I scooped around some and found a ticket from a decade ago (https://trac.osgeo.org/gdal/ticket/2318) saying I should use the Unix format ("/vsimem/file.tif"), but when doing so it raises: "'/vsimem/file.tif' not recognized as a supported file format.".

What is the proper way of doing this on Windows?

P.S.: linking to GDAL 2.0.3 64-bits, compiling with VS2017.

_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Problems creating a VSI File on Windows

Even Rouault-2
On jeudi 26 septembre 2019 10:44:21 CEST Roberto Ribeiro wrote:

> Hello list,
>
> I am trying to create a VSI File on Memory, in a W10 system, but am unsure
> how to proceed with path style.
>
> > VSIFILE* Mem = VSIFileFromMemBuffer("path", (GByte*) NewImg,
>
> (vsi_l_offset) (XSize * YSize), FALSE);
>
> > GDALDataset* DS = (GDALDataset*) GDALOpen("path", GA_ReadOnly);
>
> When doing the traditional Windows backslashes ("\\vsimem\\file.tif") it
> raises the following error when run: "'\vsimem\file.tif' does not exist in
> the file system, and is not recognized as a supported dataset name."
>
> I scooped around some and found a ticket from a decade ago (
> https://trac.osgeo.org/gdal/ticket/2318) saying I should use the Unix
> format ("/vsimem/file.tif"), but when doing so it raises:
> "'/vsimem/file.tif' not recognized as a supported file format.".
>
> What is the proper way of doing this on Windows?

/vsimem/file.tif is the proper way of doing it on all platforms

The issue here is that you pass apparently a raw buffer (nXSize * nYSize),
which is not a recognized raster format.

You likely want to use the MEM driver. Use the Create() interface, and then
fill it with your buffer with RasterIO()

Or use the MEM:::DATAPOINTER= syntax. See
https://gdal.org/drivers/raster/mem.html


--
Spatialys - Geospatial professional services
http://www.spatialys.com
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev