You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems like something went wrong during tif files generation. Basically the transformation matrix for (at least) '..._dem.tif' and '..._esaworlcover.tif' files carry wrong coordinates.
The following function may help you to fix the issue. Be aware it overwrites the file.
import os
import rasterio
from rasterio import Affine
def fix_transform(reference_s2_path, target_path):
"""Fix target file based on reference S2 band file.
"""
reference_s2 = rasterio.open(reference_s2_path)
with rasterio.open(target_path, 'r+') as target_to_fix:
target_trans = target_to_fix.meta['transform']
ref_trans = reference_s2.meta['transform']
fixed_transform = Affine(target_trans[0], target_trans[1], ref_trans[2], target_trans[3],
target_trans[4], ref_trans[5])
target_to_fix.transform = fixed_transform
if __name__ == '__main__':
path1 = './S2A_MSIL2A_20170617T113321_16_43_B01.tif'
#path2 = './S2A_MSIL2A_20170617T113321_16_43_dem.tif'
path2 = './S2A_MSIL2A_20170617T113321_16_43_esaworldcover.tif'
fix_transform(reference_s2_path=path1, target_path=path2) ```
The text was updated successfully, but these errors were encountered:
It seems like something went wrong during tif files generation. Basically the transformation matrix for (at least) '..._dem.tif' and '..._esaworlcover.tif' files carry wrong coordinates.
The following function may help you to fix the issue. Be aware it overwrites the file.
The text was updated successfully, but these errors were encountered: