SNAP: Clip Raster by Shapefile

Hi. I tried this. The process works fine, but the results are not what I wanted.

If I display the result, it gives me a picture that has the same extent as the original, but only with data in the masked area. also the used disk space went up from 1.6gb to almost 4gb.

I want everything outside of my shapefile to be clipped away…

then you will have to check “invert vector”

no - my issue is that I want to reduce file size. I want to keep just what is inside of my polygon.

The idea was that this is a better way of creating a subset, but for now it just creates the same set with a lot of no data values and more use of disk space.

ah, I see. Then the subset operator is the only way.

okay thank you. would be nice having a feature in the subset operator that can read shapefiles.

There is no way to avoid this. Raster images are rectangular arrays of data. With some file formats, the common values can be compressed. We’ll be adding compression to the file formats which will help with this.

1 Like

Hi, ABraun, I’ve posted this question here (Issue with Supervised random forest classification), maybe the only way to solve it is with the subset operator? Or is there any another way?
I dind’t yet worked with the subset operator and I don’t know anything about it , but I will try find info about how it works, if this is the only way.

Thank you for your answer.

However, I do not get how can the Land/Sea Mask tool can clip a raster based on a polygon. At least in my case, it allows only for one source file as input parameter, while a raster and a reference polygon are needed.

to be able to select the shapefile in the mask tool, you have to import it into the raster product first. Open the raster, select File > Import > Vector > Shapefile.
It will then be listed under the vector containers.

Thank you for the answer!

Hi- is there a way to clip an image with a shapefile like the subset tool does and remove everything outside of the shapefile? I am trying to use the Land/Sea Mask with a vector shapefile as mask, but keep getting an error: "A problem occured during the target product processing. Type: OperatorException Message: no product reader for band ‘null’

The Land/Sea Mask operator should actually do what you intend.

The error message seems a bit strange. Have you set all parameters?

Here is a screenshot of my processing parameters

So it did run today, but is not able to open the file, I am getting this error: Failed to open image view.

java.lang.IllegalArgumentException: expression: Undefined symbol ‘WQSF_lsb.INVALID’.

Hey guys,

I would like to crop the jp2 files (Sentinel 2) with my shapefile and export raw data (e.g. .csv, .xls) from bands 8-12. Is it possible with SNAP toolbox or if not, do you know any python library that can be useful?

Thank you in advance.
Cheers,
David

Hi Leo, I met the same problem as you. Did you solve this problem?

Maybe this could help:

Thank you! let me try.

I have the same problem but I couldn’t solve it.

1 Like

Maybe the shapefile is corrupted? Problems with shapefiles in snap - #2 by ABraun