Search code examples
pythonleafletfolium

Is there a way to make folium (python) upscale tiles when zooming in closer than tiles are available?


I'm plotting a map with the folium python package and it looks beautiful. However, the free tileset I'm using (the USGS one, listed here as "USGS.USImagery") only serves tiles up to zoom level 16.

I'd like to be able to zoom in closer than that, as I'm plotting some of my own features on top of those tiles at a higher resolution. Is there a way to tell folium to just upscale the level-16 tiles when zooming to anything above 16? I'm aware they will be pixelated, but I'd rather that than blank grey tiles.


Solution

  • See this question: Why empty tiles when zoomed "too much" in Leaflet.js? on gis.stackexchange:

    And on the folium documentation:

    max_zoom (int, default 18) – Maximum allowed zoom level for this tile layer.

    max_native_zoom (int, default None) – The highest zoom level at which the tile server can provide tiles. If provided you can zoom in past this level. Else tiles will turn grey.

    You have to set the max_native_zoom to 14 (in your example), and the max_zoom to a higher value, which matches your higher resolution features.