I want to subset SAR images to a size of 224x224 in order to analyze them using deep learning.
I understand that I can subset using two coordinates.
However, I have to give the coordinates either in latitude and longitude or in pixels.
I’m worried that if I specify only the latitude and longitude, the pixel size may not be 224x224.
Therefore,I want to subset by specifying the center coordinate and the size of 224x224.
Is there a way to achieve this using SNAP or snappy?
I hope you can translate this into Python. I was too lazy to do it. Sorry.
I also haven’t tested the code snippet if it works. But in general, it should do.
In any case you will have to project your SAR images into map coordinates for the coordinate-subsetting to work. The coordinate-information in unprojected SAR imagery can be vey imprecise or even wrong.
Thanks for the reply.
I ran the code without thinking and was happy.
I ran “Terrain-Correction” to add coordinate information.
After that, when I ran “rectangle_subset”, it was far away from the specified location.
I think the problem is the following code:
gc = product.getSceneGeoCoding()
If I pass the “product” before running “Terrain-Correction”, the result matches the specified location.
I don’t understand “getSceneGeoCoding()” correctly.
I would appreciate it if you could tell me the correct flow.
First, great that you have managed to turn the code into working Python code.
But your observation is strange.
The method getSceneGeoCoding() returns the object which encodes how the scene is geo-coded. It provides means to get the pixel position for a geo-coordinate and vice versa.
Have you checked the result of Terrain-Correction in SNAP Desktop? Can you observe something odd?
In conclusion it was a simple coding mistake on my part.
The code I shared is correct but in my code I was giving a different “product” in the function.
My apologies.