Page 1 of 1

Replace NaN by number.

Posted: Mon Jun 22, 2020 10:12 am America/New_York
by beiral
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.

Replace NaN by number.

Posted: Mon Jun 22, 2020 10:46 am America/New_York
by gnwiii
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".

Replace NaN by number.

Posted: Mon Jun 22, 2020 1:25 pm America/New_York
by beiral
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...

Replace NaN by number.

Posted: Mon Jun 22, 2020 2:43 pm America/New_York
by gnwiii
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.

Replace NaN by number.

Posted: Mon Jun 22, 2020 3:27 pm America/New_York
by beiral
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.

Replace NaN by number.

Posted: Mon Jun 22, 2020 5:13 pm America/New_York
by gnwiii
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".

Replace NaN by number.

Posted: Tue Jun 23, 2020 11:12 am America/New_York
by beiral
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!