Comparing 32 bit and 16 bit elevation GeoPackages: Difference between revisions

From Maria GDK Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
The tiled gridded coverage GeoPackage extension allows 32 bit source data to be converted to a GeoPackage with 16 bit integer tiles in PNG format, and still retain a significant number of decimals. This is accomplished by calculating a ''scale'' and ''offset'' for each tile, so that every tile utilizes the full space of the UInt16 data type (0-65536). Each tile is converted from float32 to UInt16 as follows:  
The tiled gridded coverage GeoPackage extension allows 32 bit source data to be converted to a GeoPackage with 16 bit integer tiles in PNG format, and still retain a significant number of decimals. This is accomplished by calculating a ''scale'' and ''offset'' for each tile, so that every tile utilizes the full space of the UInt16 data type (0-65536). Each tile is converted from float32 to UInt16 as follows: <syntaxhighlight lang="python3">
 
<code>
offset = min(tile)
offset = min(tile)
scale = (max(tile) - min(tile)) / (2^16 - 2)
scale = (max(tile) - min(tile)) / (2^16 - 2)
tile_png = (tile - offset) / scale
</syntaxhighlight>This formula entails that the less variation within a tile, the more of the original 32 bit precision can be retained. Leaning on Tobler's law of geography, we can assume that the variations in the terrain within any single tile will, on average, be quite small.


tile_png = (tile - offset) / scale
== Method ==
</code>
This article tests the difference between a 32 bit and 16 bit geopackage when converted from a high-resolution DTM covering a large region of Norway with varied terrain. The dataset have the following properties:
[[File:16vs32bitcomparison area.png|frameless]]
{| class="wikitable"
|+
!Name
!Data type
!Format
!Compression
!Resolution
!Projection
!File count
!Vertical accuracy
|-
|Nasjonal Detaljert Høydemodell area 11-11
|Float32
|GeoTIFF
|LZW
|1 meter
|UTM 33
|100
|Up to 10 cm
|}
Test is to do simple raster arithmetic - subtract the 16-bit dataset from the 32-bit dataset, and examine the statistics of the resulting raster dataset as a whole.

Revision as of 13:10, 14 June 2024

The tiled gridded coverage GeoPackage extension allows 32 bit source data to be converted to a GeoPackage with 16 bit integer tiles in PNG format, and still retain a significant number of decimals. This is accomplished by calculating a scale and offset for each tile, so that every tile utilizes the full space of the UInt16 data type (0-65536). Each tile is converted from float32 to UInt16 as follows:

offset = min(tile)
scale = (max(tile) - min(tile)) / (2^16 - 2)
tile_png = (tile - offset) / scale

This formula entails that the less variation within a tile, the more of the original 32 bit precision can be retained. Leaning on Tobler's law of geography, we can assume that the variations in the terrain within any single tile will, on average, be quite small.

Method

This article tests the difference between a 32 bit and 16 bit geopackage when converted from a high-resolution DTM covering a large region of Norway with varied terrain. The dataset have the following properties: 16vs32bitcomparison area.png

Name Data type Format Compression Resolution Projection File count Vertical accuracy
Nasjonal Detaljert Høydemodell area 11-11 Float32 GeoTIFF LZW 1 meter UTM 33 100 Up to 10 cm

Test is to do simple raster arithmetic - subtract the 16-bit dataset from the 32-bit dataset, and examine the statistics of the resulting raster dataset as a whole.