Export math band + lat-lon for each pixel

How can I export values for a particular math band pixels together with the latitude and longitude for that particular whole area / zone

Using ENVI or Matlab

You don’t need to use ENVI or Matlab. SNAP is all you need.

If you want special bands for latitude and longitude you can create them with Band Maths.
Create one band named latitude and use as expression LAT. Create a second band named longitude and use as expression LON.
When you export the data you can choose to export a subset or make a subset before you export it.
In the subset dialog you can choose the bands you want to include in the export.

The other option is to export a mask pixels. You can create a maks by drawing a rectangle or polygon around the area of interest or create one in the Mask Manager by using an expression.
Afterwards you can select the mask in the view and and then ricght-click in the view and choose from the context menu ‘Export Mask Pixels’. This will write a CSV file containing the data of your product including latitude and longitude. Be careful such files can easily get big.

So you see:
All you need is SNAP :musical_note: :notes:


Is there any way of doing this as a graph or writing it in the command line? I can see that you can load a vector shapefile using the graph builder, but when writing a file after that, I just get the initial TIF image I used as an input (i.e. the pixels have not been masked).

After importing the shape file, you will need to use an operator like the land/sea mask to apply the polygons as a mask on your data.

is there a way how to export mask pixels for a small particular area such as the whole area inside a polygon?
I can only export transect lines from polygons but not whole complete polygon area (including insides), on the other hand I can export a whole data set image with export mask pixels but not only for a particular small area.

problem solved… followed marpet advise :smile:


Hi Marpet,

I have been trying for sometime to create bands with lat and lon values with the gpt commands LAT and LON.
It’s working as expected within the SNAP desctop app, but not with gpt.
The gpt output band looks not right (it’s not a gradient along the whole width/length but a gradient for a tiny part of the width/length and a constant after all.

Would you please help me?

I think I have an unresolved ticket SNAP-868 which relates to my problem.
Is there a way it could be fixed anytime soon, Marpet? You prob are loaded with these tickets…

You found the issue already. (SNAP-868).

You are lucky. Actually, I just wanted to make an estimate this morning how long it would take to fix it.
Now, after seven hours it is fixed. :slight_smile:
We have planned an update for next week anyway. The fix will be released with this module update if further internal tests do not reveal a new issue with the fix.

1 Like

Marpet, I am a newbie with SNAP. Would you explain how to properly install updates?
Thanks a lot!

It is pretty easy. By default, it is done once per week and you will see a notification in the lower right corner if there are updates available.
You can trigger the check manually by going to the menu at Help / Check for Updates. And then you can follow the messages in the dialog.
Or select from the menu Tools / Plugins. Here you can see the currently installed plugins and those which are available for installation. Also, you can update the already installed plugins.

My appreciation, Marpet! :slight_smile:

1 Like

@marpet Is the first option supposed to still work? I just tried it however the exported tiff image does not contain the geogrid.

Probably you have exported the GeoTiff image via the context menu of the view.
Could you ty the product export from the menu: File -> Export -> GeoTiff

Actually that is what I am doing (i.e. Export > GeoTif). When I open the Geotif in SNAP the bands showup but not when I use Python modules I usually use. Also, when I check it with gdalinfo it shows only Band 1.

Have you tried another format? Are the bands stored in netcdf?

Yes it shows up but the image seems corrupted. Actually both the added bands (lat, lon) and the original bands (latitude, longitude) are added.Screenshot%20from%202019-04-09%2012-05-50

Can you provide the data where you want to add the bands?
I’ll send you a separate message with a link where you can upload it.