-
-
Notifications
You must be signed in to change notification settings - Fork 93
Description
Design Proposal: handle nodata in raster-dem
Motivation
In Japan, an encoding called "Numerical PNG Tile" is used by the government to distribute dem tiles. Many developers utilize it to use DEM data in WebGIS.

specification: https://maps.gsi.go.jp/development/demtile.html
This encoding is not available as is in MapLibre GL JS because it has two problem so I have to workaround by using addProtocol to modify tile contents to fit to encodings TerrainRGB or Terrarium but as it is not the best way in terms of performance.
My workaround: https://github.com/mug-jp/maplibre-gl-gsi-terrain
Problem1: nodata
This encoding has "no-data" - rgb (128, 0, 0) is treated as nodata and any height value is not defined.
It is good to set height=0 to pixels which has the nodata in ordinary cases. So, I think it is nice to set nodataRgb and nodataValue in raster-dem source.
It may be useful in other encodings when original data has pixels with no-data and they have specific rgb value.
Problem2: not "monotonically increasing"
The encoding is NOT "monotonically increasing" - it means that when red value is bigger than 2^23, we have to subtract 2^24 from value.
I don't have a good solution I can think so, then I don't propose it in this issue.
However I have tried to handle this by adding heightRange to clamp values into the range. I mean if a value is larger than maximum value, substract value toward minimum (like overflow in programming).
Proposed Change
- add
nodataRgbandnodataHeightparameters toraster-demsource.
API Modifications
{
type: "raster-dem",
tiles: ["https://cyberjapandata.gsi.go.jp/xyz/dem_png/{z}/{x}/{y}.png"],
tileSize: 256,
maxzoom: 14,
encoding: "custom",
redFactor: 655.36,
greenFactor: 2.56,
blueFactor: 0.01,
nodataRgb: [128, 0, 0], // added
nodataHeight: 0, // added
}
// means pixles with rgb=128,0,0 are treated as height = 0Migration Plan and Compatibility
none
Rejected Alternatives
none