[gdal-dev] Map Caching with GDAL

Adam Nowacki nowak at xpam.de
Fri Jan 25 17:25:46 EST 2008


marcello ferrero wrote:
> Therefore I need to access the .png (or .jpg) tile not from a file (in 
> that case I would simply use GDALOpen to open it), but from a memory buffer.
> 
> What are the GDAL functions to do what I need?
> Any help is really appreciated.

Use http://www.gdal.org/cpl__vsi_8h.html#1ecb3a78729ecea4d2ce22065a605244
to create a virtual file from memory buffer and GDALOpen it.

Here's copy/paste from WCS driver:
osResultFilename.Printf( "/vsimem/wcs/%p/wcsresult.dat", this );
FILE *fp = VSIFileFromMemBuffer( osResultFilename, pabyData, nDataLen, 
FALSE );
if( fp == NULL ) return NULL;
VSIFCloseL( fp );
GDALDataset *poDS = (GDALDataset *) GDALOpen( osResultFilename, 
GA_ReadOnly );


More information about the gdal-dev mailing list