mapbox / rio-rgbify

Encoded arbitrary bit depth rasters in pseudo base-256
MIT License
99 stars 36 forks source link

Error: RGB terrain shifted -10000 when rendered using 3d terrain (raster-dem) Maplibre GL #45

Open Fakhriyramadhan25 opened 7 months ago

Fakhriyramadhan25 commented 7 months ago

Hi there,

I am developing a 3D terrain using Maplibre GL, i want to use my own DEM data to visualize the terrain. I have converted DEM with EPSG:3857 into RGB terrain by utilizing water-gis tools. The tools comply with the MaplibreGL equation: height = -10000 + ((R 256 256 + G 256 + B) 0.1). Nonetheless, when i tried to visualize the raster-tiles into the raster-dem there is a vertical distortion occurred, it is shifted vertically, the picture as follows: base-10000

To debug this error, i have tried to change the base of the equation from (-10000) to (0) but it turns out that evoke other error to the terrain. The zoom level can only enable until 12, after that the map returns blank white screen. The base still shifted vertically but not as significant when the base is (-10000), picture as follows: base-0

Other debugging effort is by customizing the encoding of maplibre, the code as follows:

 // Use a different source for terrain and hillshade layers, to improve render quality
              terrainSource: {
                type: 'raster-dem',
                // url: 'https://demotiles.maplibre.org/terrain-tiles/tiles.json',
                tiles: ['http://localhost:5173/BDGtiles/{z}/{x}/{y}.png'],
                tileSize: 256,
                encoding: "custom",
                baseShift: 10000,
                redFactor: 0,
                greenFactor:1,
                blueFactor:1
}

The terrain touches the ground with this method but the terrain surface getting rougher and abstract. image as follows: baseshift-0

How can i repair the base shifting issue from -10000 to 0 without causing any other bug?

Thank You

notnotzero commented 4 months ago

Hi, is there are any update? @Fakhriyramadhan25 Did you find the right way to do that?

farfromrefug commented 3 months ago

@notnotzero @Fakhriyramadhan25 i personally call it that way rio rgbify --format webp -j16 -b -10000 -i 0.1 --max-z 7 --min-z 7 --round-digits 7 which i think fixes it (the -b)

etnav commented 2 months ago

@Fakhriyramadhan25 What is your Nodata value in your transofrmed DEM data? I have experienced a similar issue when converting DEM to TIFF and then TIFF to MBTiles. Setting Nodata field to None solved the issues.

alexaac commented 1 month ago

I'm having the same issue, both when I use rio rgbify or Export to MbTiles from QGIS. I've set the null values either to 0, or to an arbitrary value, I've changed base height when using rio rgbify, but I can't prepare the elevation data properly for tiling. I think it is related to the fact my original elevation data is of type Float32, but I'm not sure yet. Have you solved the issue, @Fakhriyramadhan25 ? Thanks

alexaac commented 1 month ago

It happens the same if I use the data from JAXA, and follow Bert's useful tutorial: https://bertt.wordpress.com/2022/05/24/custom-maplibre-terrain-tiles/ So it's not an issue related to the elevation data.

Screenshot from 2024-07-25 10-39-14

saricicekibrahim commented 1 week ago

First correcting dem, then converting mbtiles and xyz tiles worked for me!

chrome_56CxJ03Tds

./gdalwarp.exe -dstnodata 0 C:\Users\myPerfectUser\Documents\works\digitalTerrain\masked_turkey.tif C:\Users\myPerfectUser\Documents\works\digitalTerrain\corrected_turkey.tif

docker run --rm -ti -v "C:/Users/myPerfectUser/Documents/works/digitalTerrain/:/data" helmi03/rio-rgbify --format png -j 24 -b -10000 -i 0.1 --max-z 12 --min-z 0 corrected_turkey.tif output.mbtiles

docker run --rm -v "C:/Users/myPerfectUser/Documents/works/digitalTerrain/:/data" jskeates/mbutil /data/output.mbtiles /data/tiles