Subset image only converts values to NaNs, does not actually subset the image

We’re using GPT to do some processing on several S1B_IW_GRDH_1SDV_* files. In the last two steps we are subsetting and exporting to NetCDF4-CF. What we see is that subsetting selects the data within the subset area (as defined by a shapefile) and sets everything else to NaNs, which is correct. However, the NetCDF lat/lon extent is still the original image extent, rather than clipping to the bounding box of the shapefile. This results in a huge file when the NetCDF is uncompressed (for use in another software package).

Is there a way to subset and export images in SNAP which really subsets (i.e. reduces the lat/lon range) the data, rather than just changing cells to NaNs?

Is the subsetting based on a polygon or on coordinates?

Hello! In the mean time I realized we were using a land/water mask to subset rather than the actual subset tool, so that appears to be working now. We can remove this question from the forum (I wasn’t able to do it myself).

good to hear. I consider this issue solved but leave the topic here in case others have the same problem.

Indeed, the land/sea mask operator (using a poylgon) leaves the original size of the product while the subset operator reduces it to the entered bounding coordinates.

Is there anyone face with this displacement?
I “clipped” the image using Land/sea mask operator but I realized the file volume is still large as the original one.

Therefore, I used the real Subset operator (Raster\ Subset) to clip the original image using geography coordinates. The file size was reduced significantly. Afterward, I loaded the vector file (shapefile) to crop the image again, using Land/sea mask operator as mentioned above. However, the vector boundary and the subset SAR image was displaced and are not overlap on each other (see the below image). It is very strange. The shapefile has geography coordinate system and shows exactly the study area. But from my observation, the image also displays the correct image section that should be located inside the vector boundary.

Here is another image showing the displacement between the Preprocessed and Masked image vs the Vector boundary (shapefile in geographic coordinate).

Can you please try to import the vector before clipping to test if it overlays correctly with the data?

@ABraun,
I did import the vector file before clipping.
I firstly imported the vector file to clip the image using Land/sea Mask operator. This step was run in a Batch processing as the figure below. The result showed only the study area and masked all the outside area (as the SAR image on the left of the below image).

When I realized that the file size was not reduced, I used the Subset operator (Raster\ Subset) to clip the image using Geographic Coordinate. This subset was run as a batch processing for time-series images. Then the file size was reduced, but the location was shifted. The vector data is in the correct position, but the image sections were dislocated (one appeared closer to the vector boundary while the others may displayed further from the vector boundary). The images seemed to be “reprojected” after this step. They showed the correct area but the wrong location.

Do you know how to fix this issue?

hard to guess how this was caused.
Can you please check one time outside the graph processing tool? It would be good to understand if the error is caused by the GPT or rather by the vector itself.

1 Like

Dear @ABraun,

I re-run the image subset (using geography coordinate), and then import the vector file on each image. It is showed that the preprocessed SAR images were not projected at the correct position.

I checked the metadata, they all have WGS84(DD) map projection

very strange - I have never seen that geocoding of Sentinel-1 has produced such an offset. Did you preprocess it with the graph shown above? I see no “Import Vector” operator here.

Can you please try to run the graph without the land sea mask and check if the data is located correctly without subsetting?
You can also convert to dB during the calibration already, so you can reduce the length of the graph by one operator.

I use the below graph. No Land/Sea mask
The vector is only loaded after the Preprocess.

The problem might occur at the Apply satellite orbits

that is a different type of error. Please exclude the Orbit step and try again. The geolocation will still be good after coregistration - the question is if the data is still shifted without the Land/Sea mask operator.

I tried to redo every single step manually using the same parameters. The subset image is coregistered with the vector boundary. [The upper data frame in the below picture]

However, the subset image and vector boundary are still missed match when I run the batch processing using the same parameters. [The lower data frame in the below picture]. The error message appeared when I tried to run Land/sea mask independently after preprocessing.

thank you for comparing - this is important to narrow down the error source

@lveci: Do you see a reason why the clipping works in the GUI but there are shifts in the batch mode?

1 Like

For your information,
I rerun this batch for the last year images those were successfully applied this batch process. The displacement also occurred.

Dear @ABraun,

I repeated the process again as following steps:
[1] Apply orbit\ Thermal Noise removal\ Calibration\ Speckle Filter\ Terrain Correction\ Linear to dB.
[2] Subset was run as the last step.

If I apply the Batch process for [1] and manually apply Subset, then the images are coregistered.
If I put the Subset together in the Batch process [1 + 2], then the images are displaced.

There seems an issue with Subset function in the current SNAP version when running in Batch processing.

Do you have idea to fix this issue?

P.s: look at the below figure,

  • The left window was the result of Batch processing with Subset [1 & 2] together
  • The right window is the Batch [1] then Subset manually.

I have no explanation for this,sorry.
@marpet can we open a ticket for this, or are you aware of a similar existing issue?

I am sorry,

It does not work again when I applied for larger batch with images from different swath.
I believe other users may cope the same problem. I’m looking forward to the solutions from SNAP technical team.

Here are the result ran in a batch for different swaths. The vector file show the same location in all 4 scenes

please share one of the product IDs and the vector shapefile.

1 Like