Visualize Raster Tiles Locally using localtileserver 0.4.1 and Jupyter Notebook

Kaustav Mukherjee
2 min readFeb 8, 2022

--

pip3 install click
pip3 install flask>=2.0.0
pip3 install Flask-Caching
pip3 install flask-restx>=0.5.0
--find-links https://girder.github.io/large_image_wheels GDAL
pip3 install large-image[memcached]>=1.10
pip3 install large-image-source-gdal>=1.10
pip3 install large-image-source-pil>=1.10
pip3 install requests
pip3 install scooby
pip3 install pytest
pip3 install pytest-cov
pip3 install matplotlib
pip3 install gunicorn
pip3 install cmocean
pip3 install ipyleaflet
pip3 install shapely
pip3 install folium
pip3 install jupyter-server-proxy
pip3 install --find-links=https://girder.github.io/large_image_wheels --no-cache GDAL

Install localtileserver 0.4.1:

pip3 install localtileserver==0.4.1

If conda environment is getting used:

conda install -c conda-forge localtileserver

Setup Environment Before Running Jupyter:

##[XXX.XXX.XXX.XXX is ip address of the host default localhost]
export LOCALTILESERVER_CLIENT_HOST=XXX.XXX.XXX.XXX
##[XXXX is the port on which jupyter is running default 8888]
export LOCALTILESERVER_CLIENT_PORT=XXXX
export LOCALTILESERVER_CLIENT_PREFIX=proxy/{port}jupyter nbextension enable --py ipyleaflet

Start Jupyter:

nohup jupyter notebook &

Testing Jupyter Notebook with Tile Visualization using localtileserver:

import localtileserver
print(localtileserver.Report())
from localtileserver import get_folium_tile_layer
from localtileserver import TileClient
from folium import Map
import folium
# First, create a tile server from local raster file
tile_client = TileClient('/DISK003/SPATIAL_ANALYTICS/landuse.tif')
# Create folium tile layer from that server
t = get_folium_tile_layer(tile_client)
m = Map(location=tile_client.center())m.add_child(t)m

Running localtileserver Docker Image:

docker run -p 8888:8888 -v /path/of/rasterized-tiff/:/data/ ghcr.io/banesullivan/localtileserver-jupyter:latestThen add the ?filename= parameter to the URL in your browser to access the local files. Since this is mounted under /data/ in the container, you must build the path as /data/<filename on Desktop>, such that the URL would be: http://localhost:8000/?filename=/data/TC_NG_SFBay_US_Geo.tif

--

--

Kaustav Mukherjee

DISTRBUTED DEEP LEARNING ARCHITECT,DATA PHILOSOPHER,MACHINE LEARNING ON REAL-TIME STREAMS