Skip to content

77 split raster

image image image

Uncomment the following line to install leafmap if needed.

1
# %pip install -U leafmap
1
import leafmap

Create an interactive map and add a raster layer to it.

1
2
3
4
m = leafmap.Map()
url = "https://opengeos.org/data/raster/cog.tif"
m.add_cog_layer(url, name="COG")
m

Split the raster layer into multiple tiles.

1
leafmap.split_raster(url, out_dir="tiles", tile_size=(100, 100), overlap=0)

Show the tiles.

1
leafmap.find_files("tiles", ext=".tif")

Merge the tiles into a single raster dataset.

1
leafmap.merge_rasters("tiles", output="merged.tif", input_pattern="*.tif")