32 local tile
Using local raster datasets or remote Cloud Optimized GeoTIFFs (COG) with leafmap
Uncomment the following line to install leafmap and localtileserver if needed.
In [1]:
Copied!
# !pip install leafmap localtileserver
# !pip install leafmap localtileserver
In [2]:
Copied!
import os
import leafmap
import os
import leafmap
Specify input raster datasets
In [3]:
Copied!
out_dir = os.path.expanduser('~/Downloads')
dem = os.path.join(out_dir, 'dem.tif')
landsat = os.path.join(out_dir, 'landsat.tif')
out_dir = os.path.expanduser('~/Downloads')
dem = os.path.join(out_dir, 'dem.tif')
landsat = os.path.join(out_dir, 'landsat.tif')
Download samples raster datasets.
In [4]:
Copied!
if not os.path.exists(dem):
dem_url = 'https://drive.google.com/file/d/1vRkAWQYsLWCi6vcTMk8vLxoXMFbdMFn8/view?usp=sharing'
leafmap.download_from_gdrive(dem_url, dem, out_dir, unzip=False)
if not os.path.exists(dem):
dem_url = 'https://drive.google.com/file/d/1vRkAWQYsLWCi6vcTMk8vLxoXMFbdMFn8/view?usp=sharing'
leafmap.download_from_gdrive(dem_url, dem, out_dir, unzip=False)
In [5]:
Copied!
if not os.path.exists(landsat):
landsat_url = 'https://github.com/giswqs/leafmap/raw/master/examples/data/cog.tif'
leafmap.download_from_url(landsat_url, landsat, out_dir, unzip=False)
if not os.path.exists(landsat):
landsat_url = 'https://github.com/giswqs/leafmap/raw/master/examples/data/cog.tif'
leafmap.download_from_url(landsat_url, landsat, out_dir, unzip=False)
Create an interactive map.
In [6]:
Copied!
m = leafmap.Map()
m = leafmap.Map()
Add local raster datasets to the map. The available palettes can be found at https://jiffyclub.github.io/palettable/
In [7]:
Copied!
m.add_local_tile(landsat, band=[4, 3, 2], layer_name="Landsat")
m.add_local_tile(landsat, band=[4, 3, 2], layer_name="Landsat")
In [8]:
Copied!
m.add_local_tile(dem, palette='viridis', layer_name="DEM")
m.add_local_tile(dem, palette='viridis', layer_name="DEM")
In [9]:
Copied!
m
m
Out[9]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Add a remote Cloud Optimized GeoTIFF(COG) to the map.
In [10]:
Copied!
m = leafmap.Map()
m = leafmap.Map()
In [11]:
Copied!
url = 'https://opendata.digitalglobe.com/events/california-fire-2020/pre-event/2018-02-16/pine-gulch-fire20/1030010076004E00.tif'
url = 'https://opendata.digitalglobe.com/events/california-fire-2020/pre-event/2018-02-16/pine-gulch-fire20/1030010076004E00.tif'
In [12]:
Copied!
m.add_remote_tile(url, layer_name="CA Fire")
m.add_remote_tile(url, layer_name="CA Fire")
In [13]:
Copied!
m
m
Out[13]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Last update:
2022-03-14