3

I would like to be able to read a part of a TIFF file as a numpy array (using read as array(xoff, yoff, xsize, ysize) and be able to export it again to TIFF file, having this subset its correct coordinates. I was thinking obtaining the Geotransform from the original file, and adding/substracting from its coordinates, the offsets multiplied by the pixel size. I think that would give me the correct Geotransform to apply it when exporting. Would that be correct? Would there be any other way? (I dont want to use gdal_translate for this process).

4

That will work as long as your images aren't rotated, i.e. gt[2] == gt[4] == 0. Have a look at rasterio if you're not tied to straight-up gdal: https://rasterio.readthedocs.io/en/latest/topics/windowed-rw.html#data-windows

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.