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).

0

1 Answer 1

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

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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