Skip to content

GeoTiff

mtbeek32 edited this page Feb 13, 2023 · 35 revisions

The (Geo)Tiff format is our advised format for grid data, as it:

  • is open, widely used, binary(fast) and supports multiple compression types.
  • allows geo-referencing projection information to be embedded with (in an accompanying .tfw world file in the same folder) or within the GeoTiff file.

(Geo)Tiff files can be read and written to with the GeoDMS.

Read

The GeoDMS supports two ways of reading csv files:

  • gdal.grid: for most (Geo)Tiff files, we advice to use gdal.grid (see next subparagraph), except for:
    • uint2, uint4 and boolean data.
    • palette based (Geo)Tiff files
  • tiff StorageManager

gdal.grid

The following example shows how to read a (Geo)Tiff file with gdal.grid.

example

Examples for reading AHN data from the file 26az2.tiff:

unit<spoint> AHNTile
:   StorageName = "%SourceDataDir%/AHN/26az2.tif" 
,   StorageType = "gdal.grid" 
,   DialogData  = "Geografie/rdc" 
{    
   attribute<float32> GridData;    
   attribute<float32> ReadData (subdomain); 
}

The primary data is read from the 26az2.tif file. The projection information can also be read from this file, or from a 26az2.tfw file in the same folder. The DialogData property needs to refer to the unit for the coordinate system (RD, LatLong etc) to inform the GeoDMS on how to relate the projection information from the GeoTiff to the coordinate system of the configuration.

The geographic grid domain AHNTile is implicitly defined by the projection information and the number of rows/columns of the GeoTiff.

The GridData attribute has this AHNTile as domain unit and is read for the whole grid.

The ReadData attribute reads a subset of the data for another domain unit, in the example subdomain. This geographic domain unit needs to be configured and can be used to read for example the AHN data for a building or the land use for a country from a European land use file. If only a (small) selection of a GeoTiff file is needed, using such a ReadData attribute as it is much faster than reading the GridData and making the selection afterwards.

Data read from a GeoTiff is automatically tiled in the GeoDMS.

Tiff StorageManager

unit<spoint> AHNTile
:   StorageName = "%SourceDataDir%/AHN/26az2.tif" 
,   DialogData  = "Geografie/rdc" 
{
   attribute<float32> GridData;
   attribute<float32> ReadData (subdomain); 
}

tiles

Grids can be split up in tiles. The following example shows how a grid is split up in a Tiled Domain with tiles of 1024 * 1024 grid cells.

unit<spoint> AHNTile
:   StorageName = "%SourceDataDir%/AHN/26az2.tif" 
,   StorageType = "gdal.grid" 
,   DialogData  = "Geografie/rdc" 
{   
   unit<wpoint>       AHNSubTile := TileUnit(point(1024w,1024w,AHNTile); 
   attribute<float32> ReadData (AHNSubTile); 
}

The ReadData attribute reads the data of the whole grid file for the TiledDomain: AHNSubTile.

TrueColor

In this variant GeoTiff files contain a color value (rgb code) for each grid cell. The GeoDMS supports TrueColor Bitmap/Tiff images with 24 bits per pixel (1 byte for red, green and blue values). The value type for the grid data values in the GeoDMS needs to be: uint32.

Example:

unit<spoint> referentie_tiff
:   StorageName = "%projDir%/data/tif/kaart.tif"
,   DialogData  = "Geography/point_rd"
{
   attribute<uint32> GridData: DialogType ="BrushColor";
}

The property DialogType = "BrushColor" is configured to inform the GeoDMS the grid values are interpreted as colors and can be used directly to visualise grid cells in the map view.

palette based

In this variant GeoTiff files contain an index number for each grid cell. These index numbers are related to colors in a palette. The palette is also stored in the GeoTiff file. Based on the number of entries in the palette (related to the number of different colors in the file), the griddata of a palette based GeoTiff is usually configured with value type uint4 (for 16 colors) or uint8 (for a maximum of 255 colors).

Example:

unit<uint4> colorindex;
{
   attribute<uint32> palette := Grid/PaletteData
  ,  DialogType = "BrushColor";
}
unit<spoint> referentie_tiff
:   StorageName = "%projdir%/data/tiff_pa.tif"
,   DialogData  = "Geography/point_rd"                    
{
   attribute<colorindex>  GridData;
   attribute<units/color> PaletteData (colorindex);
}

The subitem named GridData refers to the index numbers. The subitem named PaletteData is an attribute with a domain unit that is unifiable with the values unit of the GridData attribute. The PaletteData is also read from or written to the Tiff file.

The property DialogType = "BrushColor" is configured for the palette subitem of the palette domain to inform the GeoDMS that the palette values are to be interpreted as colors when visualizing the grid cells in a map view.

Other palettes (not directly read from the Tiff file) can also be used, e.g. defined explicitly in the GeoDMS configuration.

aggregations

Aggregations can be made from the GeoTiff file by using the SqlString property.

If a SqlString = "number" is configured, a relation is made (if possible) between the grid data domain and the result domain based on the configured projection. This relation is used to count the number of occurrences of the configured class number in the original Tiff file for the new desired grid cell.

Clone this wiki locally