localtileserver

raw JSON →
1.0.0 verified Fri May 01 auth: no python

Locally serve geospatial raster tiles in the Slippy Map standard. Version 1.0.0, active development, monthly releases.

pip install localtileserver
error ModuleNotFoundError: No module named 'localtileserver'
cause The package is not installed or installed in a different environment.
fix
Run pip install localtileserver in the correct Python environment.
error ImportError: cannot import name 'get_leaflet_tile_layer' from 'localtileserver'
cause Trying to import a function that was renamed or moved. Prior to version 1.0.0, it was `get_leaflet_tile_layer`, now it's available at top level.
fix
Use from localtileserver import get_leaflet_tile_layer.
gotcha The tile server runs in the background and uses a random port by default. If you have firewall or Docker issues, set the port explicitly with `TileClient('file.tif', port=5000)` to avoid conflicts.
fix Use `port` parameter: `TileClient('file.tif', port=8080)`.
gotcha TileClient's `__del__` method stops the server garbage collection may not run immediately in interactive sessions. Call `client.close()` explicitly to free the port, or use `with TileClient(...) as client:`.
fix Use context manager: `with TileClient('file.tif') as client:` or call `client.close()` after use.

Serve a local GeoTIFF as slippy map tiles and display in a Jupyter notebook with ipyleaflet.

from localtileserver import TileClient, get_leaflet_tile_layer
from ipyleaflet import Map

client = TileClient('path/to/raster.tif')
tile_layer = get_leaflet_tile_layer(client)
m = Map(center=(40.7128, -74.0060), zoom=10)
m.add_layer(tile_layer)
m