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
# !pip install leafmap
In [2]:
Copied!
# !pip install localtileserver
# !pip install localtileserver
In [3]:
Copied!
import leafmap
import leafmap
Specify input raster datasets
In [4]:
Copied!
dem = "dem.tif"
landsat = "landsat.tif"
dem = "dem.tif"
landsat = "landsat.tif"
Download samples raster datasets.
In [5]:
Copied!
dem_url = (
"https://drive.google.com/file/d/1vRkAWQYsLWCi6vcTMk8vLxoXMFbdMFn8/view?usp=sharing"
)
leafmap.download_file(dem_url, dem, unzip=False)
dem_url = (
"https://drive.google.com/file/d/1vRkAWQYsLWCi6vcTMk8vLxoXMFbdMFn8/view?usp=sharing"
)
leafmap.download_file(dem_url, dem, unzip=False)
dem.tif already exists. Skip downloading. Set overwrite=True to overwrite.
Out[5]:
'/home/runner/work/leafmap/leafmap/docs/notebooks/dem.tif'
In [6]:
Copied!
landsat_url = "https://github.com/opengeos/leafmap/raw/master/examples/data/cog.tif"
leafmap.download_file(landsat_url, landsat, unzip=False)
landsat_url = "https://github.com/opengeos/leafmap/raw/master/examples/data/cog.tif"
leafmap.download_file(landsat_url, landsat, unzip=False)
landsat.tif already exists. Skip downloading. Set overwrite=True to overwrite.
Out[6]:
'/home/runner/work/leafmap/leafmap/docs/notebooks/landsat.tif'
Create an interactive map.
In [7]:
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 [8]:
Copied!
m.add_raster(landsat, indexes=[4, 3, 2], layer_name="Landsat")
m.add_raster(landsat, indexes=[4, 3, 2], layer_name="Landsat")
In [9]:
Copied!
m.add_raster(dem, colormap="viridis", layer_name="DEM")
m.add_raster(dem, colormap="viridis", layer_name="DEM")
In [10]:
Copied!
m
m
Out[10]:
Add a remote Cloud Optimized GeoTIFF(COG) to the map.
In [11]:
Copied!
m = leafmap.Map()
m = leafmap.Map()
In [12]:
Copied!
url = "https://github.com/opengeos/data/releases/download/raster/Libya-2023-07-01.tif"
url = "https://github.com/opengeos/data/releases/download/raster/Libya-2023-07-01.tif"
In [13]:
Copied!
m.add_cog_layer(url, name="Maxar")
m.add_cog_layer(url, name="Maxar")
In [14]:
Copied!
m
m
Out[14]: