[Gdal-dev] Create method

Frank Warmerdam warmerdam at pobox.com
Fri Sep 24 10:01:28 EDT 2004

Pereira, Ricardo Scachetti wrote:
>         Hi, folks,
>         GDAL supports creation of many raster formats from table on this 
> url: _http://www.remotesensing.org/gdal/formats_list.html_
>         But then when I check if the drivers support the Create method, 
> with a call like this:
>   poDriver = GetGDALDriverManager()->GetDriverByName("AAIGrid");
>   if( poDriver == NULL ) exit( 1 );
>   papszMetadata = poDriver->GetMetadata();
>   bool result = ( CSLFetchBoolean( papszMetadata, GDAL_DCAP_CREATE, 
> FALSE ) );
>         Only BMP and Gtiff seem to support it.
>         So my question is, what is the alternative method of creating 
> raster datasets using the various drivers, other than using Create()? 
> Why some drivers implement it and others don't?


There are basically two ways of creating files with GDAL.  One pre-creates
the file, and then you use the various GDAL "set" functions and the
RasterIO() calls to write out metadata and image data.  This is the Create()

The other approach is to use the CreateCopy() in which case you have to
provide an input file that has the configuration you want in the output
file and it will copy everything to the new file before returning control.

Many formats only support CreateCopy() because it is often difficult to
implement "random update".  For instance, when writing a PNG file you need
to do things in a particular order.  The colormap may need to be written
first, and once the image data is written (always top to bottom) it cannot
be updated again.

So for formats where I am constrained by the underlying library, or challenges
in the format itself I will generally only implement CreateCopy().

However, there should be several formats that do support direct Create(),
including (I think) VRT, NITF, HFA, MEM, PCIDSK and possibly a few others.

Best regards,
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent

More information about the Gdal-dev mailing list