Subset with shapefile not exact polygon shape

I am trying to subset my data set of S1 and S2 with respect to small shapefiles. I did preprocess for S1 and S2 and stacked them. In the end, I subset images with the polygons. Then I overlayed results on the shapes to see if they fit. The results are like:
What I was expected is to subset the images in exact or very close shape as shapefiles (and filling the extents with NaN value) but snap subsets them on extents of the shapefile. I want to know what is the probable cause of this problem. And what should I do differently?
For subsetting, I used very usual snappy code like:
parameters = HashMap()
parameters.put(‘geoRegion’, wkt)
output = GPF.createProduct(‘Subset’, parameters, source)

Currently, SNAP does not remove the pixels outside the polygon bounds, but they get a fixed value (most likely 0, you can check with the info cursor in QGIS).
Once you know this value, you can set it to “no data” in the QGIS raster layer properties.


This is intended behaviour.
The output of SNAP always needs to be a rectangular raster. That’s why you get the bounding box of the shapefile.
What @Braun said is not done automatically if just the subset operator is used.
But you can use the Import Vector and Land-Sea-Mask operators to mask the outer region.
This post might help:


Thank you @ABraun and @marpet for your quick response. Actually, in the meanwhile, I tried to do the subsetting with the snap desktop using Land\mask operator and import vector and it worked fine. So I was more confused. I did not know I can do that with snappy as well. I will give it a try. Thank you for your answers.

1 Like