[gdal-dev] Using MEM driver to output to an gtiff in /vsimem/
Even Rouault
even.rouault at mines-paris.org
Tue Mar 29 18:35:59 EDT 2011
Le mercredi 30 mars 2011 00:17:17, Bborie Park a écrit :
> 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
> );
--> Here, you must close the dataset so it to be properly flushed before
getting the buffer.
>
> 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
More information about the gdal-dev
mailing list