I am a new into Python. I have processed 1000 NDVI rasters covering larger area. I need to burn those NDVI raster with Water mask. The water mask came for whole world I need to subset AOI and also want to subset the same AOI for the 1000 NDVI rasters. I want rows, column should be same so that I can burn with each other.

I have tried with https://automating-gis-processes.github.io/CSC18/lessons/L6/clipping-raster.html, but it gives same rows column for all NDVI rasters but the no of columns and rows are changed when I subset the water mask with same cordinates.

I have tried with gdal.translate()

from osgeo import gdal

from shapely.geometry import box

minx, miny = 3.59, 41.14

maxx, maxy = 15.92, 49.27

bbox = box(minx, miny, maxx, maxy)

ds = gdal.Open('/scratch/test_reproject/20030416_1335_ndvi_reprojected_proj4.tif')
ds = gdal.Translate('/scratch/test_reproject/output/20030416_1335_ndvi_reprojected_proj4_crop_gdal.tif', ds, projWin = [3.59, 41.14,  15.92, 49.27])
ds = None

from osgeo import gdal

from shapely.geometry import box

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.