77 split raster
Uncomment the following line to install leafmap if needed.
In [ ]:
Copied!
# %pip install -U leafmap
# %pip install -U leafmap
In [ ]:
Copied!
import leafmap
import leafmap
Create an interactive map and add a raster layer to it.
In [ ]:
Copied!
m = leafmap.Map()
url = "https://open.gishub.org/data/raster/cog.tif"
m.add_cog_layer(url, name="COG")
m
m = leafmap.Map()
url = "https://open.gishub.org/data/raster/cog.tif"
m.add_cog_layer(url, name="COG")
m
Split the raster layer into multiple tiles.
In [ ]:
Copied!
leafmap.split_raster(url, out_dir="tiles", tile_size=(100, 100), overlap=0)
leafmap.split_raster(url, out_dir="tiles", tile_size=(100, 100), overlap=0)
Show the tiles.
In [ ]:
Copied!
leafmap.find_files("tiles", ext=".tif")
leafmap.find_files("tiles", ext=".tif")
Merge the tiles into a single raster dataset.
In [ ]:
Copied!
leafmap.merge_rasters("tiles", output="merged.tif", input_pattern="*.tif")
leafmap.merge_rasters("tiles", output="merged.tif", input_pattern="*.tif")