-
Notifications
You must be signed in to change notification settings - Fork 1
GeoTiff
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.
The GeoDMS supports two ways of reading (Geo)Tiff 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
The following example shows how to read a (Geo)Tiff file with gdal.grid.
The (GeoTiff) file contains the data of a tile of the AHN, in this case: 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.
GDAL options can be configured for reading (Geo)Tiff files with gdal.grid.
See: https://gdal.org/drivers/raster/gtiff.html#open-options for a full list of all open options.
The following example shows how to read a (Geo)Tiff file with the tiff StorageManager.
The (GeoTiff) file is one tile of the AHN, in this case: 26az2.tiff.
unit<spoint> AHNTile : StorageName = "%SourceDataDir%/AHN/26az2.tif" , DialogData = "Geografie/rdc" { attribute<float32> GridData; attribute<float32> ReadData (subdomain); }
The configuration is quite similar to the gdal.grid variant, only the StorageType does not have to be configured.
As GDAL does not support Sub Byte Element GeoTiff files, we advice to use the Tiff StorageManager to read boolean, uint2 and uint4 data.
Both the gdal.vect and the tiff StorageManager can read TrueColor (Geo)Tiff files.
The essence of a TrueColor Tiff is that the GridData contains a color value (rgb code) for each grid cell. The GeoDMS supports TrueColor Bitmap/GeoTiff 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.
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.
In this variant the GridData attribute contain index numbers 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).
Palette based can at the moment only be read with the tiff StorageManager.
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.
the SqlString property is in use for (Geo)Tiff files for 2 purposes:
-
Aggregations 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.
-
Multiple bands The following example shows how to read multiple bands (only with gdal.grid)
unit<uint32> grid_uint8_nth_band : StorageName = "%SourceDataDir%/intput/tiff_uint32.tif" , StorageType = "gdal.grid" , DialogData = "units/point_rd" , StorageReadOnly = "True" { attribute<uint8> Red : SqlString="BANDS=1"; attribute<uint8> Blue : SqlString="BANDS=2"; attribute<uint8> Green : SqlString="BANDS=3"; attribute<uint8> Magenta : SqlString="BANDS=4"; }
The GeoDMS supports two ways of writing (Geo)Tiff files:
- gdalwrite.grid: for most (Geo)Tiff files, we advice to use gdalwrite.grid (see next subparagraph), except for:
- uint2, uint4 and boolean data.
- palette based (Geo)Tiff files
- tiff StorageManager
!!! We noticed some issues with writing GeoTiff files with gdalwrite.grid. We advices to use the tiff StorageManager instead of gdalwrite.grid at the moment.
The following example shows how to write a (Geo)Tiff file with gdalwrite.grid.
unit<spoint> Export_AHNTile := AHNTile : StorageName = "%LocalDataProjDir%/AHN/26az2.tif" , StorageType = "gdalwrite.grid" { attribute<float32> GridData := AHNTile/Export_AHNTile; }
GDAL options can be configured for writing (Geo)Tiff files with gdal.grid.
See: https://gdal.org/drivers/raster/gtiff.html#creation-options for a full list of all creation options.
The following example shows how to write a (Geo)Tiff file with the tiff.
unit<spoint> AHNTile : StorageName = "%LocalDataProjDir%/AHN/26az2.tif" { attribute<float32> GridData:= AHNTile/Export_AHNTile; }
In the same way as with reading, the configuration for writing GeoTiff files is quite similar to the gdalwrite.grid variant, only the StorageType does not have to be configured.
As GDAL does not support Sub Byte Element GeoTiff files, we advice to use the Tiff StorageManager to write boolean, uint2 and uint4 data.
In this variant the GridData attribute contain index numbers 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).
Palette based can at the moment only be written with the tiff StorageManager.
unit<uint4> colorindex { attribute<units/color> palette := Grid/PaletteData, DialogType = "BrushColor"; } unit<spoint> Read: StorageName = "%projdir%/data/tiff_pa.tif", DialogData = "units/point_rd", StorageReadOnly = "True" { attribute<colorindex> GridData; attribute<units/color> PaletteData (colorindex); } container Write: StorageName = "%localDataProjDir%/regr_results/tiff_pa.tif", ExplicitSuppliers = "Read" { attribute<colorindex> GridData (Grid) := Grid/GridData; attribute<units/color> PaletteData (colorindex) := Grid/PaletteData; }
GeoDMS ©Object Vision BV. Source code distributed under GNU GPL-3. Documentation distributed under CC BY-SA 4.0.