Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Fakhriyramadhan25 opened this issue Jan 19, 2024 · 8 comments

Comments

@Fakhriyramadhan25
Copy link

Fakhriyramadhan25 commented Jan 19, 2024

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
Copy link

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

@farfromrefug
Copy link

@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
Copy link

etnav commented Jun 24, 2024

@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
Copy link

alexaac commented Jul 24, 2024

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
Copy link

alexaac commented Jul 25, 2024

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
Copy link

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

@samdyra
Copy link

samdyra commented Sep 24, 2024

Hi @Fakhriyramadhan25, I hope you're doing well

Have you managed to solve the base shifting issue? I’ve been encountering a similar problem, and I’m curious if you found a solution.

Additionally, I’m facing a blank white screen when accessing certain zoom levels (~13-14) with tiles from GeoServer's WMTS. Have you come across this issue as well, and if so, have you been able to resolve it?

Thanks a lot in advance!

@alexaac
Copy link

alexaac commented Sep 25, 2024

Hi @samdyra ,

Here is an explanation: https://bertt.wordpress.com/2022/05/24/custom-maplibre-terrain-tiles/
"The earth is modelled as an ellipsoid, this ellipsoid is the vertical reference. Where terrain is added (for Andorra between z = 1000 and z = 3000 meter above the ellipsoid) it will show up elevated, where there is no terrain it will stay at the ellipsoid reference (z = 0)."

Regarding the blank white screen, it is a bug from MaplibreGL: maplibre/maplibre-gl-js#1542

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants