On their official blog, I found a 2019 post mentioning that the technique encodes elevation data into the RGB channels of an image and then decodes it in the browser. This allows elevation visualization directly in the browser—especially for continuous profile data—by downloading a few images to plot a continuous elevation curve.
On GitHub, I found the syncpoint/terrain-rgb project, which provides a complete guide for converting elevation data into RGB images.
I placed my organized code into the ringsaturn/play-terrain-rgb repository. The workflow is identical to @syncpoint’s, with only minor parameter differences and source data variations.
Creating output file that is 914P x 756L.
Processing ASTGTMV003_N35E138_dem_clip.tif [1/1] : 0...10...20...30...40...50...60...70...80...90...100 - done.
Inspect the reprojected file’s information:
1
rio info --indent 2 ASTGTMV003_N35E138_dem_clip_EPSG3857.tif
Next, to display on a map, we need to convert the RGB image into tiles. I used the gdal2tiles.py tool:
1
time gdal2tiles.py --zoom=5-19 --processes=16 ASTGTMV003_N35E138_dem_clip_EPSG3857.RGB.tif ./tiles
1
2
3
4
5
Generating Base Tiles:
...10...20...30...40...50...60...70...80...90...100 - done.
Generating Overview Tiles:
0...10...20...30...40...50...60...70...80...90...100 - done.
gdal2tiles.py --zoom=5-19 --processes=16 ./tiles 1332.07s user 360.34s system 1297% cpu 2:10.39 total
Note: If you regenerate tiles multiple times, gdal2tiles.py will modify the zoom range in the generated HTML, so you may need to manually adjust it depending on your situation.
Finally, we can convert the tiles into MBTiles format using mb-util: