Remove the raster region that overlaps with polygon shapefile


I am trying to remove (erase) the raster region that overlaps with a polygon shapefile. This way the size of the raster 2D array would reduce during computation.

Can you provide an insight into how to proceed? I can do it Arc but the rasters are too big to transfer and would require a lot of time.



once you imported it in SNAP save your product and open it again. Your geometry is now also listed under “masks”. Let’s say it is named polygon in SNAP.
You can then define a valid pixel expression (under the properties of the band): polygon = 0

Hi @ABraun, but if it is still part of the image 2D array, whether valid or invalid, the image size would not reduce. That is the main reason that I want to remove the image region that overlaps with the polygon shapefile. The image tile after masking is still same as the original image.


You’re right.
You can compute the raster with 0 at those pixels in the band maths (IF polygon = 0 THEN 0 ELSE rastername). This would not shorten the array but maybe of the raster product.

Thanks @ABraun, I will continue with the masking part rather than clipping the data. That is because the bounding box of the clipped image might still be same size as image tile or maybe 80% of the original size of the tile. Changing the land region to NaN and skipping NaN data should be equally fast computation wise when compared to clipped data.