1

I'm making a project. I need to open a local GeoTIFF file and load it into the Folium map with PyQt5. For now, instead of GeoTIFF, I took a numpy array. If it is 500,500,3 shape, everything is fine.

import sys import numpy as np import io from PyQt5 import QtWidgets, QtWebEngineWidgets from PyQt5.QtWidgets import QDesktopWidget import folium if __name__ == '__main__': app = QtWidgets.QApplication(sys.argv) bounds_fin = [[30, 35], [35, 45]] center_lat = bounds_fin[0][0] + ((bounds_fin[1][0] - bounds_fin[0][0]) / 2) center_lon = bounds_fin[0][1] + ((bounds_fin[1][1] - bounds_fin[0][1]) / 2) m = folium.Map(location=[center_lat, center_lon], zoom_start=6) arr = np.random.random((500,500,3)) image_layer = folium.raster_layers.ImageOverlay( image=arr, name="I am a test array", bounds=bounds_fin, opacity=0.7, zindex=1 ) image_layer.add_to(m) folium.LayerControl().add_to(m) data = io.BytesIO() m.save(data, close_file=False) w = QtWebEngineWidgets.QWebEngineView() w.setHtml(data.getvalue().decode()) q = QDesktopWidget().availableGeometry() w.show() sys.exit(app.exec_()) 

and result

enter image description here

If shape is 1000,1000,3 arr = np.random.random((500,500,3)) for some reason the image does not load (just a white background in my case, even the Folium map is not visible). enter image description here

This is the case on both Linux and Windows.

What am I doing wrong? Сan Folium render large arrays, or is it impossible?

1 Answer 1

0

As a result, I came to this decision: since I need to open GeoTIFF in any case, I use the localtileserver library, which cuts GeoTIFF into tiles in real time. Code below

from localtileserver import get_folium_tile_layer, TileClient .... tile_client = TileClient(fileNameGeoTIFF) foliumMap = folium.Map( location=tile_client.center(), tiles=None, zoom_start=10,max_zoom=15,min_zoom=1, ) tile_layer = get_folium_tile_layer(tile_client, name='test', control=True, overlay=True) foliumMap.add_child(tile_layer) .... 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.