Gpt Subset geometry and pixel mixed (for match-up)

Hello, I try to to subset a scene around a given co-ordinate but not by a geometry (WKT) but by pixels:
pixel hit by co-ordinate plus neighbouring pixels.
Is there an option in subset to do this or an feasible other way to do this in batch by gpt?
Thanks for any help
hajo

Hi Hajo,

maybe the PixEx tool can help you.
You can find it in the menu at Raster / Export / Export Pixel Values
There you can specify the pixel by geo-coordinates and define a window region around this pixel.
Enable the sub-scene export and you can specify an additional border
You can let this run on multiple products or just a single one. You can also invoke it from the command line via gpt, if you put the parameterization in a graph.

Thank you - I knew the PixEx tool, but never used it to get subscenes. I found the check-box Sub-scenes but I fail now too. I get nice textfiles with pixel information as desired but I can’t find any subscene (I am still running on snap6)

If no error occured there should be a folder named “subScenes” in the output directory.

However, I noticed that this is probably not what you want. Because you get one subset for each product, not for each coordinate. The subset contains all coordinates within the source product.

You could use snappy to create the subsets.
This script could serve as a starting point.

1 Like

Oops - I overlooked the subScenes. Now everythings works interactively in snap. I may come back when I try to make a batch using gpt.
But so far
Thank you

Hi!
the snappy script you pointed out does not fit my purpose (I think)
because I need exactly the central point and the surrounding eight pixel.

I made now a gpt batch with this xml:
subset_pixex.xml (1.2 KB)
first the PixEx writing an intermediate BEAM-DIMAP file
then Read the Dimap and Write an nc4 file

together with a python wrapper which is called like this:
./subset_pixex.py -i /pathto/S3-scene.SEN3
subset_pixex.py (1.1 KB)
That works so far.

My question (not urgent any longer):
is it possible when using PixEx to avoid the writing of intermediate files and products like the SubScene folder with content
but directly write an NetCDF4-BEAM out of the graph?

No this is not really possible.

Maybe it is just better to use the subset operator.
Within Python find the pixel-coordinate for the geo-coordinate you are looking for and extended for the additional surrounding pixels.
Provide this rectangle as the region parameter.

Maybe something like the following snippet. I didn’t let it run, so it might still contain some errors.
import sys

from snappy import ProductIO, GeoPos, HashMap, Rectangle

file = sys.argv[1]
GeoPos = GeoPos(15.786082, 45.30223)

print('Reading...')
product = ProductIO.readProduct(file)

pixelPos = product.getSceneGeoCoding().getPixelPos(GeoPos(), None)
rect = Rectangle(pixelPos.x, pixelPos.y, 1, 1)
rect.grow(2, 2)

parameters = HashMap()
parameters.put('region', rect)
sub_product = GPF.createProduct('Subset', parameters, product)

print('Writing...')
ProductIO.writeProduct(sub_product, 'snappy_subset_output.nc', 'NetCDF4-BEAM')

print('Done.')

I tried the subset operator earlier,
but that did not really work for me, because depending on the geometry I got always in some few cases (scenes) not a 3x3 pixel result but 2x3, 4x3, 3x2, or 3x4.
The problem was the varying orientation of the scene versus the orientation of my search (WKT) geometry which was fixed.

You suggest now to make it dynamic with snappy.
This is exactly I was looking for, but because my current solution with PixEx gave me my results
I will try it later - Thank you