Extract pixel values

Have you selected “Write to file“?

If so, could you please share the txt file in here?

S2A_MSIL2A_20180911T073611_N9999_R092_T38SPH_20190902T180719_resampled_msk_TRANSECT.txt (9.5 KB)

Now I understand. I suggested “Export Transect Pixels” which only exports the pixels along the polygone line.
To have the full area, “Export Mask Pixels” is required. This is inactive until you save the product (after digitizing the polygon)

grafik

File > Save Product

grafik

4 Likes

Thanks for your attention. Solved.:pray::pray:

Hello export,

I was trying to expert backscatter coefficient and incident angle from my study area scene using this method but “Export Mask Pixels” option is marked as grey that i am unable to select that, even after saving the product. Please help me to export my pixel values as .CSV file.

It should help if you close and reopen the image view, where you have drawn the shape.
I have added a ticket to our bug tracker for this: [SNAP-1352] Mask not shown in product view after creation

Thank you marpet, I did try the method, and it works and the file format is .txt, but I need the pixel values in .CSV format. So is there any option there to extract pixel values with my desired file format?

You can simply exchange the file ending. CSV is just a special type of a text file. The content is tab separated.
Alternatively you can go to the menu at File / Export / CSV. In the file dialog you click on the subset button and select the are you want. Then save the file to disk. This will be a bit different format. But it is also CSV and it has this file ending.
For details of this format, please have a look at the help:

This is what i got, while extract the .csv file using File / Export / CSV option.

. I am not getting the attributes.

When you export as CSV your NaN values will appear as blanks. I am not able to see in your screenshot if you have values later on the file (you have more than 3000 rows). A fast solution would be to convert you .txt into .csv in Excel. In any case, both formats can be tab separated, if that is what you need.

can you please upload the CSV here?

its showing the file is too big to upload here. My file is approximately 400 MB.

you can make a copy and only use the first 100 lines, for example.

I got the problem which I was getting previously, that is the null values of the raster image. I fixed that and got the values that I need. S1_20200421.csv (210.6 KB)

1 Like

Great that you have been able to solve it. Could you also tell us how you did it?
What was the reason for the null values?

Previously I had tried to extract the values of the entire Terrain Corrected scene, later i tried with some polygon shape, which excluded the null values and include the pixel with some values only. Thank you for your help.

1 Like

This is the help I was looking for. My next question: what band order is the output? I’m seeing 1,2,3,4,5,6,7,8,9,10,11,12,13 does 9 translate to 8A?

I want to extract pixel values of 20 sigma nought images under some shapefile. Is there any method to extract values of all 20 images at once not one by one?

The pixel export for a region is not yet implemented. But it is on the todo list ( [SNAP-828] The pixel extraction to be extended to support geometries instead of coordinates only).
But you can do a subset and export this as CSV. But this will include more pixels as your region, because the export is always rectangular.
See

With a processing chain you could at least set the pixels outside of your region to no-data.
Here I have provided an example:

1 Like

Depending on how you plan to use the CSV files, a GIS or other popular package may be more useful. It is important to remember that developers are a scarce resource, so users are better off when SNAP Developers can focus on capabilities specific to remote sensing that aren’t available from existing widely used tools (ArcGIS, QGIS, etc.).