Locally serve geospatial raster tiles in the Slippy Map standard.
Project description
🚀 Support This Project
If localtileserver saves you time, powers your work, or you need direct help, please consider supporting the project and my efforts:
🌐 Local Tile Server for Geospatial Rasters
Need to visualize a rather large (gigabytes+) raster? This is for you.
A Python package for serving tiles from large raster files in
the Slippy Maps standard
(i.e., /zoom/x/y.png) for visualization in Jupyter with ipyleaflet or folium.
Launch a demo on MyBinder
Documentation: https://localtileserver.banesullivan.com/
Built on rio-tiler and FastAPI
🌟 Highlights
- Launch a tile server for large geospatial images
- View local or remote raster files with
ipyleafletorfoliumin Jupyter - Band math expressions for on-the-fly computed imagery (e.g., NDVI)
- Per-band statistics and multiple image stretch modes
- Multiple output formats: PNG, JPEG, WebP, GeoTIFF, NPY
- Spatial subsetting via bounding box crops and GeoJSON masks
- STAC item support for multi-asset catalogs
- Xarray DataArray tile serving (NetCDF, Zarr, etc.)
- Virtual mosaics from multiple raster files
- View rasters with CesiumJS with the built-in web application
- Full REST API powered by FastAPI with auto-generated OpenAPI docs
🚀 Usage
Usage details and examples can be found in the documentation: https://localtileserver.banesullivan.com/
The following is a minimal example to visualize a local raster file with
ipyleaflet:
from localtileserver import get_leaflet_tile_layer, TileClient
from ipyleaflet import Map
# First, create a tile server from local raster file
client = TileClient('path/to/geo.tif')
# Create ipyleaflet tile layer from that server
t = get_leaflet_tile_layer(client)
m = Map(center=client.center(), zoom=client.default_zoom)
m.add(t)
m
Band Math Expressions
Compute derived imagery on the fly using band math expressions:
client = TileClient('path/to/multispectral.tif')
# NDVI: (NIR - Red) / (NIR + Red) where NIR=b4, Red=b1
t = get_leaflet_tile_layer(client, expression='(b4-b1)/(b4+b1)',
vmin=-1, vmax=1, colormap='RdYlGn')
STAC Support
Visualize assets from STAC catalogs:
import requests
# Fetch tiles from a STAC item's assets
resp = requests.get('http://localhost:PORT/api/stac/tiles/10/512/512.png',
params={'url': 'https://example.com/stac/item.json',
'assets': 'visual'})
Xarray DataArrays
Serve tiles directly from xarray DataArrays (NetCDF, Zarr, etc.):
import xarray as xr
ds = xr.open_dataset('temperature.nc')
da = ds['temperature']
da = da.rio.write_crs('EPSG:4326')
# Register and serve tiles through the REST API
ℹ️ Overview
The TileClient class can be used to launch a tile server in a background
thread which will serve raster imagery to a viewer (usually ipyleaflet or
folium in Jupyter notebooks).
This tile server can efficiently deliver varying resolutions of your raster imagery to your viewer; it helps to have pre-tiled, Cloud Optimized GeoTIFFs (COGs).
There is an included, standalone web viewer leveraging CesiumJS.
REST API
The server exposes a comprehensive REST API built on FastAPI:
| Endpoint | Description |
|---|---|
GET /api/tiles/{z}/{x}/{y}.{fmt} |
Raster tiles |
GET /api/thumbnail.{fmt} |
Thumbnail preview |
GET /api/metadata |
Raster metadata |
GET /api/bounds |
Geographic bounds |
GET /api/statistics |
Per-band statistics |
GET /api/part.{fmt} |
Bounding box crop |
POST /api/feature.{fmt} |
GeoJSON mask extraction |
GET /api/stac/tiles/{z}/{x}/{y}.{fmt} |
STAC item tiles |
GET /api/xarray/tiles/{z}/{x}/{y}.{fmt} |
Xarray DataArray tiles |
GET /api/mosaic/tiles/{z}/{x}/{y}.{fmt} |
Mosaic tiles |
GET /swagger/ |
Interactive API docs |
All tile/thumbnail endpoints support expression, stretch, indexes, colormap, vmin, vmax, and nodata query parameters.
⬇️ Installation
Get started with localtileserver to view rasters in Jupyter or deploy as your
own FastAPI application.
🐍 Installing with conda
Conda makes managing localtileserver's dependencies across platforms quite
easy and this is the recommended method to install:
conda install -c conda-forge localtileserver
🎡 Installing with pip
If you prefer pip, then you can install from PyPI: https://pypi.org/project/localtileserver/
pip install localtileserver
Optional Dependencies
For xarray/DataArray support:
pip install localtileserver[xarray]
For Jupyter widget integration:
pip install localtileserver[jupyter]
For additional colormaps:
pip install localtileserver[colormaps]
💭 Feedback
Please share your thoughts and questions on the Discussions board. If you would like to report any bugs or make feature requests, please open an issue.
If filing a bug report, please share a scooby Report:
import localtileserver
print(localtileserver.Report())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file localtileserver-1.0.0rc1.tar.gz.
File metadata
- Download URL: localtileserver-1.0.0rc1.tar.gz
- Upload date:
- Size: 97.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31c154c428c840a234420a9bf6402278b8344f38e8867e7afc922de072ddef62
|
|
| MD5 |
09d4eaad1a77aa0dd0eddde801331a27
|
|
| BLAKE2b-256 |
701352e5c01b58e9befa14e3037e5d97e81b17d113c599818f4b862058f80ffe
|
Provenance
The following attestation bundles were made for localtileserver-1.0.0rc1.tar.gz:
Publisher:
release.yml on banesullivan/localtileserver
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
localtileserver-1.0.0rc1.tar.gz -
Subject digest:
31c154c428c840a234420a9bf6402278b8344f38e8867e7afc922de072ddef62 - Sigstore transparency entry: 1352259112
- Sigstore integration time:
-
Permalink:
banesullivan/localtileserver@5440d99358e007d87633eb74186c9fc325a01f91 -
Branch / Tag:
refs/tags/v1.0.0rc1 - Owner: https://github.com/banesullivan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5440d99358e007d87633eb74186c9fc325a01f91 -
Trigger Event:
push
-
Statement type:
File details
Details for the file localtileserver-1.0.0rc1-py3-none-any.whl.
File metadata
- Download URL: localtileserver-1.0.0rc1-py3-none-any.whl
- Upload date:
- Size: 33.7 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b94012848e07e58c3876c68a9c2ea2b4fc272657b429c74ee957a45bba10aa6
|
|
| MD5 |
142c27e7b18659dd2ade1756f82387c1
|
|
| BLAKE2b-256 |
3b5656b4e55f29926406483656494e1a573ab42254662cb381e3d5a86a4c59c2
|
Provenance
The following attestation bundles were made for localtileserver-1.0.0rc1-py3-none-any.whl:
Publisher:
release.yml on banesullivan/localtileserver
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
localtileserver-1.0.0rc1-py3-none-any.whl -
Subject digest:
4b94012848e07e58c3876c68a9c2ea2b4fc272657b429c74ee957a45bba10aa6 - Sigstore transparency entry: 1352259304
- Sigstore integration time:
-
Permalink:
banesullivan/localtileserver@5440d99358e007d87633eb74186c9fc325a01f91 -
Branch / Tag:
refs/tags/v1.0.0rc1 - Owner: https://github.com/banesullivan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5440d99358e007d87633eb74186c9fc325a01f91 -
Trigger Event:
push
-
Statement type: