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

Even Rouault even.rouault at spatialys.com
Thu Sep 26 06:56:40 PDT 2019


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


More information about the gdal-dev mailing list