GeoTIFFOverlay not working (not showing image) in Dash Leaflet

I'm developing a dashboard using Dash Leaflet, and I want to use the function GeoTIFFOverlay, in order to display a TIFF image on the map: this is the code for testing purpose that I'm using:

import dash
import dash_leaflet as dl
from dash import Dash, html

app = dash.Dash()

tiff_path = 'assets/test-tiff.tif'
png_path = 'assets/test-png.png'
bounds_png = [[34.113362591, 4.379137166], [48.020394545, 20.420888158]]
bounds_tiff = [34.113362591, 4.379137166, 48.020394545, 20.420888158]


app = dash.Dash()
app.layout = html.Div(
    [
        dl.Map(
            [
                dl.LayersControl(
                    [
                        dl.Overlay(
                            [
                                # dl.ImageOverlay(url=png_path, bounds=bounds_png)
                                dl.GeoTIFFOverlay(
                                    url=tiff_path, bounds=bounds_tiff)
                            ],
                            name="Map", checked=True)
                    ],
                    position="topleft"
                ),
                dl.TileLayer()
            ],
            bounds=bounds_png,
            style={'width': '600px', 'height': '400px'}
        )
    ]
)


if __name__ == '__main__':
    app.run_server(debug=True, port=8090)

As you can see from the code, I tried with ImageOverlay and it works perfectly (with a png), and also with different bounds, while with the TIFF the image is not even shown.

Anyone have a solution?

Thanks in advance.

Upvotes: 0

Views: 810

Answers (1)

Ryski
Ryski

Reputation: 11

Unfortunately I can't be much help beyond pointing out that it is quite easy to have an invalid tiff as most readers are very generous, but I know google uses a very strict reader that has tripped me up before. You could try decompressing it if it is LZW'd or otherwise I've managed to fixed tiffs before by re-saving with photoshop or using ImageMagick/GraphicsMagick on *unix by doing an idempotent convert (i.e. .tiff -> .tiff, though I have noticed some older versions of those can create LZW compression errors though so be sure to update if that happens to be your pipeline).

I would like to also know the answer though, obligatory bump, as I am learning dash currently as an alternative frontend to matplotlib and will need dl.map to be displaying tiffs otherwise I am wasting my time.

Upvotes: 0

Related Questions