0

Edit: I have changed the clip to updateMask function. when I print the image dimensions it seems to be ok with size, but when I export image GCS and then open again, it adds empty row /column to the image. I couldn't find any reason why.

I have two images which are different size . I want to clip img2 using img 1, and to get image that has the exactly same dimensions as img1.

img1 has the following shape: [425, 327] img2 has the following shape: [426, 329]

I have tried to clip them using GEE as following:

img1=ee.Image.loadGeoTIFF(url_one)
img2=ee.Image.loadGeoTIFF(url_two)



clipped=img2.UpdateMask(img1.select('B1'))

#print of imgs size
sz_clip=clipped.getInfo()['bands'][0]['dimensions']
sz_img2=img2.getInfo()['bands'][0]['dimensions']
sz_orig=img1.getInfo()['bands'][0]['dimensions']

print(f'img1 size:{sz_orig}  img2 size"{sz_be}    clipped size: {sz_clip}')

>>>
original size:[425, 327]  img2 size"[426, 329]    clipped size: [426, 328]

My problem is that I need to get the clipped img with the same size as img1, but this doesn't happen and I get something new.

I though maybe it has to do with projection, so I have tried to do the same but to reproject img2 to have the same projection as img 1 before clipping:


projection_img1=sen.projection()

img2_reproj=img2.reproject(crs=projection_img1)

#tried also like this but same size result:
img2_reproj=img2.reduceResolution(reducer=ee.Reducer.mean()).reproject(crs=projection_img1)

...

original size:[425, 327]  img2 size"[426, 329]    clipped size: [426, 328]

I still don't have clipped_size with the same size as img1.

My end goal is to have the clipped image with the exactly same shape as img1.

1 Answer 1

0

Are the two images registered / georeferenced? Do they overlap the way you'd expect when imported? Can you share the assets that were imported?

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.