kkmcgg / floodmap

Web-Based Flood Mapping Experiment
https://kkmcgg.github.io/floodmap/
0 stars 0 forks source link

Increase Vertical Resolution #1

Open kkmcgg opened 1 year ago

kkmcgg commented 1 year ago

Currently the index is using open layers and accessing the image tiles of the ArcGIS image server not the raw 32bit version. Image Server: https://agrgims.cogs.nscc.ca:6443/arcgis/rest/services/ElevationModels/HRDEM_dtm_1m_utm20/ImageServer

One way or another - this is reducing the apparent Z resolution to whole meters (this is perhaps confusion coincidence, the scaled values must be approx 0-255 m??)

Either way - this needs to be resolved as we see the flood layers definitely 'jump' by about a meter.

One way to resolve this is to host the elevation as 3*8b RGB is used in the sea-level open layers example https://openlayers.org/en/latest/examples/sea-level.html https://docs.mapbox.com/data/tilesets/reference/mapbox-terrain-rgb-v1/

kkmcgg commented 1 year ago

note that for compressing this elevation to RGB the highest point in the Maritimes is Mount Carleton NB, 820 m. PEI is (unnamed) ~ 142 m. NS is White Hill,CB at 693 m. NFLD is Cabox at 812 m. LAB is Mount Caubvick at 1652 m.

kkmcgg commented 1 year ago

note I have demo'd this locally in experiments/RGB_elevation.mxd layer 8b elevation RGB which uses a method I call Super CSR! image

kkmcgg commented 1 year ago

I am having issues with the 'super csr' concept above. the RGB HSV conversion is unfortunately not preserving the bit depth consistently across the color range (which results in noise banding).

Instead, it may be better to stick with a simple RGB packing ala Mapbox.

Encoding:

normalizedElevation = (elevation - minValue) / (maxValue - minValue)
packedValue = normalizedElevation * (2^24 - 1)
R = floor(packedValue / 2^16) % 256
G = floor(packedValue / 2^8) % 256
B = packedValue % 256

Decoding:

unpackedValue = R * 2^16 + G * 2^8 + B
decodedElevation = (unpackedValue / (2^24 - 1)) * (maxValue - minValue) + minValue