0

I have tiff files extracted from google earth engine from the same boundary location. I open these files using rasterio in python and then convert them into numpy array. But what happens is that despite the numpy arrays showing the same area they're misaligned. How can I fix this. I'm using the code below to read the tiff files and save them

import rasterio as rs
from rasterio.plot import reshape_as_image
from skimage import exposure
import numpy as np
import cv2

raster_file = reshape_as_image(rs.open(file_path).read())
mask = np.ones_like(raster_file)
mask[np.isnan(raster_file)] = 0
img_fixed = exposure.equalize_hist(raster_file,mask=mask)
img_fixed *= 255
img_fixed = img_fixed.astype('uint8')
png_file_path = file_path[:-4] + ".png"
cv2.imwrite(png_file_path, img_fixed)

One of the images is sentinel-1 ASCENDING VH 2022 and the other one from the same satellite and DESCENDING VV 2018 when using the data from the same year I don't have such a problem they're exactly aligned but when they're from different years they're not. I appreciate any help :)

Sentinel-1 ASCENDING VH 2022 Sentinel-1 DESCENDING VV 2018

javid
  • 35
  • 6

1 Answers1

0

It seems that the problems is the different crs of the tif files. The solutions are either to download tif files using the same crs files (Google earth engine has an argument for this here is how to do this) or simply convert the existing tif file crs. Rasterio can reproject files in a different crs formats. Here is an example

javid
  • 35
  • 6