[GIS] Add DEM layer to Leaflet

demgeotiff-tiffleaflet

I want to add a digital elevation model (DEM) layer to my leaflet map and access the height data through javascript, i.e. I cannot use .png files or qgis2webplugin but rather .tif or some compressed webmaptile file.

Any efficient idea or plugin recommendation?

Best Answer

You will have to dump that tiff file (or whatever) into a <canvas> and read the values of whatever pixels you want. Be aware of cross-origin issues.

Do read:

https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Using_images

https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Pixel_manipulation_with_canvas