The forum is locked.

The Ocean Color Forum has transitioned over to the Earthdata Forum (https://forum.earthdata.nasa.gov/). The information existing below will be retained for historical reference. Please sign into the Earthdata Forum for active user support.

- By beiral Date 2020-06-22 14:12
Hi all!

I've got some .L3m turbidity maps which has some NaN values. I need to replace every NaN value by the number -9999.
Can someone help on how can I do it, through Math Band, for example?
Thank's for any help!

Beiral.
- By gnwiii Date 2020-06-22 14:46
You can replace NaN's with other values using the nan() function in Band Math expressions, but since NetCDF4-CF is used by current OCSSW processing tools it is worth mentioning NetCDF best practices for handling "missing data values".
- By beiral Date 2020-06-22 17:25
I did use the (nan) function, but the NaN values weren't replaced and the values different of NaN became 0....so the NaN didn't become a number...
Any ideia why does this happens? I'm really stuck at this...
- By gnwiii Date 2020-06-22 18:43
How are you checking the values?  Did you save the image to a file, and if so what image format?   NaN's are special floating point values, so if the image is stored as unsigned integers they have to be translated to a format-specific "missing data" value.
- By beiral Date 2020-06-22 19:27 Edited 2020-06-22 19:36
The math band generates the new raster and I'm checking it on the own Seadas. I'm not exporting or saving the raster. I acctually do want to export it as Geottif to work on arcgis; but since the NaN isn't being replaced by a number there's no reason for me to export the raster image.
At Math Band I'm using .L3m images and the following expression: "if turb==NaN then 9999 else turb".
Any ideia from that, sir George?
And about this unsigned integers, how could I translate to this format-specific "missing data" value? And I don't really know if my image is stored as unsigned integers; how can I verify that?

Thank you very much for your time and help sir!

Beiral.
- By gnwiii Date 2020-06-22 21:13
Recent versions of ArcGIS can import NASA's standard product NetCDF4-CF files directly.  There are many advantages to NetCDF4-CF: automatic missing-value handling, proper band names, and detailed metadata.   My GIS using colleagues find NetCDF4-CF saves time compared to geoTIFF's because more of the work of setting band names, units, etc. are done for you.  

A good way to get an overview of the contents of a geoTIFF or NetCDF4-CF  file is with GDAL's gdalinfo.  Note that NetCDF4-CF files often contain multiple bands, so you use "gdalinfo <filename>" once to find the band you want, then "gdalinfo NETCDF:<filename>:<bandname>".  

SeaDAS provides the nan function because NaN is defined in way that tests of the form you tried: "if turb==NaN then 9999 else turb" don't work and have to written as "if nan(turb) then 9999 else turb", or using a Ternary Conditional Operator "nan(turb) ? 9999 : turb".   Rather than trying set a special value in Band Math, use the  
Property Editor to set a "Valid Pixel Expression".
- By beiral Date 2020-06-23 15:12
Your Band Math expression worked perfectly for what I needed.
About using the ArcGIS, I'm really more used to work with geoTIFF files on that, but considering those advantages on NetCDF4-CF I'll check it out.

Thank you for your help sir. Have a very nice day!