[GRASS-dev] GDAL write support

Glynn Clements glynn at gclements.plus.com
Sat Dec 6 04:27:19 EST 2008


I have committed preliminary, minimal, experimental, barely-tested
support for creating new maps via GDAL (i.e. like r.external, but in
the opposite direction).

The feature is enabled with r.external.out, which allows you to
optionally set the format (default GeoTIFF), extension (default none;
use e.g. extension=.tif to set it), directory where output files are
stored (default: <mapset>/gdal/) and any creation options (passed
directly to the driver).

Thereafter, any new raster maps will be generated via GDAL. The maps
should automatically be available to GRASS, as if they had been linked
with r.external.

Running "r.external.out -r" will revert to creating maps natively. 
Maps previously created via GDAL should still work.

Limitations include (but probably aren't limited to):

1. The data type for integer maps is determined by
G_set_cell_format(), meaning that it will normally be Int32. Unlike
r.out.gdal, we don't know the range of the data when the output file
is opened.

2. If the driver for the format doesn't support direct writing, the
data will intially be written via the memory driver, then copied to
the file upon close. I'm guessing that this requires the map to fit
into memory. r.external.out should print a warning if you choose such
a driver.

3. If you write data type which the format can't handle (e.g. writing
Float64 to PNG), you lose.

4. Colour tables aren't included in the file. GRASS treats colour
tables as distinct entities; the code which creates the raster data
doesn't know about the colour table, or if one will even be created. 
Colour tables are normally only written after the map is closed, at
which point it may be too late to add it to the image file.

5. Projection information isn't written either. The code which would
need to do this is in lib/gis, which can't use e.g. GPJ_grass_to_wkt()
from lib/proj because of circular dependency issues. I suppose that I
could make r.external.out create a WKT version of the projection data,
but then you run into problems if the projection is subsequently
changed.

6. You can't store multiple maps in a single multi-band file.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list