RGB pixel info and positioning

I need to export the rgb data in numerical form for each pixel plus the x,y co-ordinates
plus the lat and long data in a txt file. (pls refer to image) Is there an available function which can help me here.

You can do the following:

  1. Create a subset containing only the three RGB bands.
  2. Create a mask cover the whole image (expression = ‘true’)
  3. Open one of the bands (not the RGB)
  4. Export the mask pixels. Select from the context menu of the image view the item ‘Export Maks Pixels’.

The export takes some time.

Faster, but more steps:

  1. Create a subset containing only the three RGB bands.
  2. Add new Bands with Band Math
    1. band name = latitude; expression = LAT
    2. band name = longitude; expression = LON
    3. band name = pixelX; expression = X
    4. band name = pixelY; expression = Y
  3. Export as CSV file. Menu: File / Export / CSV

This is how the output will look like (just the first lines):

featureId	B2:float	B3:float	B4:float	latitude:float	longitude:float	pixelX:float	pixelY:float
0	0.0979	0.0582	0.0409	37.94732	21.000114	0.5	0.5
1	0.105	0.0655	0.0441	37.94732	21.000797	1.5	0.5

The second approach is the one I would suggest. The mask export is to slow. I’ve added this as an issue to our bug tracker (SNAP-932).

1 Like

Thanks Marpet