Subset using Vector file

Dear All,
I need to subset sentinel 1 data using a vector data, i.e., from a shapefile.

is there any option to do so? I need only the region within the shapefile. kindly help


Is it only this file or several files. Do you want let it run on the command line?
In the Desktop Application you can for example zoom to region and then right click on the image and choose ‘Spatial Subset from View’. Then save the resulting product to disk.
On the command line you can use gpt and the Subset operator. This operator does not support a shapefile but you can specify a region in WKT format.
Try calling gpt -h and gpt -h Subset for some help.

1 Like

Thank you. This actually solved my problem.

Just for the records, the option to use a shapefiles to subset/mak a products is also well-hidden within the “Land/See Mask” operator (under Raster --> Mask).


Yes. This option is much more easier to use. Thanks a ton


that was insightful indeed.

Hello, I have the same problem, i would like to subset the processed S1 data with a shapefile, i used the Land/Sea mask as recommended above, I imported the shapefile and overlayed on the S1 image, then I used the Land/Sea Mask, then I selected (use vector as Mask), but it does not work with me, I mean the output was only the outlines of the shapefile and the outside is black, but i did not find the subset of S1 image, may be i used it in a wrong way, So please let me know what is the problem, or how to use it in the right way, thanks

1 Like

is your shapefile a polyline or a polygon?

I have the same problem, what is the difference if it is a polyline or a polygon?

Hi ABraun, It is Polygon

A polyline is only the outline of a shape. A polygon is an area, it includes the interior.

can you please post a screenshot of your image with the polygon in it?

Hi marpet since SNAP can I load a shape file for to do a subset ???

yes, open any image in snap and select menu > import > vector data > ESRI Shapefile

1 Like

I can’t tell you a specific date. But I just raised the priority for this issue.
Maybe you will see this issue in the second half of this year.

Hi @ABraun
I want to get a subset of my image, based on a shapefile of my area. I used the address Raster > Mask > Land/Sea Mask as you noted, and the area that I got was correct, but I couldn’t remove the vector file of the image. Furthermore, since the shapefile is added, each process result that I get, has a Mask layer. how can I remove it? Would you please help me fix these problems?
Thanks in advance :slight_smile:

You can remove it by hitting the DEL-key. Select it in the Product Explorer and select the shape from the Vector Data group and hit DEL. The same for the mask in the Masks group.

1 Like

Hello @marpet and hello everyone. I’ve read your previous posts but I’m stuck with a problem and can’t come up with a solution.
I have to subset a S-1 image with a rectangular polygon but when I do that using the subsetting algorithm (I’m using it via snappy module in python) I don’t really get the exact portion I want.
This is the picture with the subset polygon:

this is the code I use to compute the subset:

import os
import snappy
from snappy import HashMap, ProductIO, GPF, jpy

HashMap = jpy.get_type('java.util.HashMap')
#Get snappy operators    
source = ProductIO.readProduct('')


        # Get subset geometry from WKT file

        import csv
        with open(r'E:\Users\Davide_Marchegiani\SoilMoisture\Data\REMEDHUS\qgis_data\remedhus_subset_off0.083.csv') as csvfile:
                csv_read = csv.reader(csvfile)
                for row in csv_read:
                        wkt = (row[0])
        # Set SUBSET parameters

        parameters = HashMap()
        parameters.put('geoRegion', geom)
        prod1 = GPF.createProduct('Subset', parameters, source)
        ProductIO.writeProduct(prod1,'prova_SUBSET', 'BEAM-DIMAP')

The WKT geometry is taken from the following CSV file:

"POLYGON((-5.69732514465564 41.0610034077076,-5.69732514465564 41.5702974448227,-5.07043043612034 41.5702974448227,-5.07043043612034 41.0610034077076,-5.69732514465564 41.0610034077076))",remedhus_subset_off0.083

This is the result I obtained:

Now why I don’t get exactly the vector portion as a subset? Is there a way to force snap to crop exactly that portion?

I’ve tried using the Land/see mask operator as well but the problem is that the output image size is the same as the input:

I would like to have a smaller image with only the “not-black” portion of the last image…is there a way of doing that?
Thank you!

The problem is that image raster data is always rectangular. So that’s why after Subset also the outer area is visible.
We have it already on the list to improve it (SNAP-369).
You can use both operations in conjunction. First, do the subset afterwards apply the Land/see mask operator on the result.

The image I want is rectangular as well. I think the problem is in how SNAP displays every image, cause it does regardless of the CRS and thus of the real position of the image itself. It just opens the image in a virtual horizontal-vertical axis, while the “real image” would be rotated. Am I wrong?