Batch "Export mask pixel"?

Hi,

I have 120 different ponds deliminated by polygons and would like to retrieve pixel values from within all of them separately. Is there a way to batch process the Export mask pixel tool from within SNAP?

Thanks for your help,
Arthur

I have no solution for SNAP but you could use the Zonal Statistics plugin of QGIS to get a mean/min/max/median… value of all pixels within each polygon.

You can select the geometries in the Statistics Window for which you want the numbers.


This is a bit tedious if you have 120 regions.
This can also be done on the command line with gpt. Type gpt StatisticsOp -h for help. Also in the forum it is already mentioned.
If you just want the values within the regions then it is only possible via right click on the view in the desktop application and chose Export Mask Pixels. For each region separately. Would be awesome if one could select multiple here. (I’ll add it as an issue)

You can easily export to envi compatible formats. You can choose File/Export/ENVI for example. Or if you save the product as BEAM Dimap then you can open the files in the *.data directory in envi.

1 Like

Thank you for your replies!

Since we don’t expect the ponds to be homogenous we are trying not to use the mean values from our polygons.

What would be awesome would be to have the same type of output as the Export Mask Pixels tool mentionned by marpet in the previous post, but with an added column being “MASK_ID” or something similar.
Even better would be to be able to do this in multiple products at the same time (load all available pictures, apply masks to all of them and then extract pixels per pond per date.

I’ll be trying to do so using R and/or QGIS

I think the Pixel Extraction tool should be extended in a way that it supports also masks/geometries not only single coordinates.

This can then be also called from the command line on a stack of products.

1 Like

Hi,

I also need to export pixel values from several hundred polygons from several hundred S2 Scenes.
I managed to do so via the SNAP GUI: --> Import Vector File and then Export “Mask Pixels”. This works fine for a single S2 Scene…

Is there already a methode to batch this process in SNAP via the “Graph Builder” and/or Python or any other method ?

Thanks for any help

1 Like

It would be super excellent to be able to call “Export Masked Pixels” in gpt, so that it could be run on many images! Are there any plans for this?

1 Like

Yes, there are plans to support this, but I can’t say a specific date at the moment. However there are way to do it now.
Use the BandMaths operator to create a product which contains only the mask data. And then you can export it to CSV format. This might already help, even if it does not have the desired format.

2 Likes

it would also be necessary to export coordiantes of pixels belonging to that masked values. At the moment this can be done with Export/Mask Pixel tool, but only from the SNAP Desktop …

1 Like

We ended up writing an R script that would extract all pixel values from a list of coordinates made with “Export Masked Pixels” in SNAP. We were then able to extract pixel values from all scenes within VITO’s MEP virtual machine environment.

1 Like