74 map tiles to geotiff
Downloading maps tiles and converting them to a GeoTIFF file
Disclaimer: The leafmap.map_tiles_to_geotiff()
function is adapted from the tms2geotiff repo. Credit goes to the GitHub user @gumblex.
Uncomment the following line to install leafmap if needed.
In [1]:
Copied!
# %pip install -U leafmap
# %pip install -U leafmap
In [2]:
Copied!
from leafmap import leafmap
from leafmap import leafmap
Create an interactive map.
In [3]:
Copied!
m = leafmap.Map()
m
m = leafmap.Map()
m
Use the drawing tools to draw a rectangle on the map.
In [4]:
Copied!
if m.user_roi is not None:
bbox = m.user_roi_bounds()
else:
bbox = [-122.5216, 37.733, -122.3661, 37.8095]
if m.user_roi is not None:
bbox = m.user_roi_bounds()
else:
bbox = [-122.5216, 37.733, -122.3661, 37.8095]
Download map tiles and create a GeoTIFF file. First, let's try Esri world imagery basemap.
In [5]:
Copied!
leafmap.map_tiles_to_geotiff("satellite.tif", bbox, zoom=13, source="Esri.WorldImagery")
leafmap.map_tiles_to_geotiff("satellite.tif", bbox, zoom=13, source="Esri.WorldImagery")
Downloaded image 1/15 Downloaded image 2/15 Downloaded image 3/15 Downloaded image 4/15 Downloaded image 5/15 Downloaded image 6/15 Downloaded image 7/15 Downloaded image 8/15 Downloaded image 9/15 Downloaded image 10/15
Downloaded image 11/15 Downloaded image 12/15 Downloaded image 13/15 Downloaded image 14/15 Downloaded image 15/15 Saving GeoTIFF. Please wait... Image saved to satellite.tif
In [6]:
Copied!
leafmap.map_tiles_to_geotiff("topo.tif", bbox, zoom=13, source="OpenTopoMap")
leafmap.map_tiles_to_geotiff("topo.tif", bbox, zoom=13, source="OpenTopoMap")
Downloaded image 1/15 Downloaded image 2/15 Downloaded image 3/15 Downloaded image 4/15 Downloaded image 5/15
Downloaded image 6/15 Downloaded image 7/15 Downloaded image 8/15 Downloaded image 9/15 Downloaded image 10/15 Downloaded image 11/15 Downloaded image 12/15 Downloaded image 13/15 Downloaded image 14/15 Downloaded image 15/15 Saving GeoTIFF. Please wait...
Image saved to topo.tif