[gdal-dev] Using MEM driver to output to an gtiff in /vsimem/

Bborie Park bkpark at ucdavis.edu
Tue Mar 29 18:17:17 EDT 2011


Hi,

What I'm attempting to do is write some code to do the following:

PostGIS Raster -> GDAL MEM -> user specified GDAL output format in 
/vsimem/ (e.g. GTiff) -> return contents of the output file to user

I'm able to successfully create a MEM dataset with raw band data 
specified using the DATAPOINTER creation option and the GDALRasterIO() 
function from a PostGIS Raster.  I've been successful outputting the MEM 
dataset using CreateCopy() to a GTiff stored on the filesystem (e.g. 
/tmp/out.tif), such as...

rtn_ds = GDALCreateCopy(
	rtn_drv,
	"/tmp/out.tif",
	src_ds,
	FALSE,
	options,
	NULL,
	NULL
);

What does not seem to work is if I use CreateCopy with a /vsimem/ path.

rtn_ds = GDALCreateCopy(
	rtn_drv,
	"/vsimem/out.tif",
	src_ds,
	FALSE,
	options,
	NULL,
	NULL
);

rtn = VSIGetMemFileBuffer("/vsimem/out.tif", &j, FALSE);

When I read /vsimem/out.tif back out to pass back to the end-user, the 
contents are significantly shorter than what it should be.  From what I 
can tell, the contents outputted are just the tiff header information 
and none of the band data.

Is there something different about outputting a raster to a filesystem 
rather than /vsimem/ when working with a MEM raster with external band data?

Thanks,
Bborie

-- 
Bborie Park
Programmer
Center for Vectorborne Diseases
UC Davis
530-752-8380
bkpark at ucdavis.edu


More information about the gdal-dev mailing list