Skip to main content
Question

How to change NaN to NoData?


makt
Contributor
Forum|alt.badge.img+1
  • Contributor
I have a workflow where I am creating a raster using SurfaceModeler. As documented, this transformer may output some NaN values when using PLANAR interpolation. I indeed have a few cells that come out with a NaN value.

 

 

I am not certain what transformer can change my NaN values to NoData values (or any other values)?

 

 

I read through this article: http://blog.safe.com/2013/11/fmeevangelist119/

 

and thought the NullAttributeMapper would be the answer, but it does not seem so.

 

 

 
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

19 replies

fmelizard
Safer
Forum|alt.badge.img+20
  • Safer
  • November 17, 2014
try the nodatasetter.

takashi
Celebrity
  • November 18, 2014

 

Hi,

 

 

Have you tried setting a preferable Nodata value to the "Output DEM Raster Nodata Value" parameter of the SurfaceModeller?

 

 

Takashi

fmelizard
Safer
Forum|alt.badge.img+20
  • Safer
  • November 18, 2014
Your error suggest that the value nan is not acceptable for a raster , try a numeric value such as 9999 or 0 for your nodata value.

makt
Contributor
Forum|alt.badge.img+1
  • Author
  • Contributor
  • November 18, 2014
Hey Talashi - I already have a NoData value that is working, which is -32767.0, then I also have NaN cells as well so I don't think this setting is what I am looking for.

 

 

Itay - I think you are getting at the NoData value? My understanding of NaN is that is is not a number so it would not be 9999 or 0.

 

 

To simply my question: given that you have a 32 bit raster that has normal double values, has a NoData value set as -32767.0, and also has NaN values, what is the simplest way to make the NaN values into NoData values?

 

 

I have managed to do this but I'm not sure how efficient the process would be with larger datasets:

 

I first convert the raster to points, then do a AttributeClassifier (passing only points that are "double") and then using NumericRasterizer to arrive back at a raster. This does the trick but is there a more efficient method?

 

 

 

fmelizard
Safer
Forum|alt.badge.img+20
  • Safer
  • November 18, 2014
I would try the RasterCellValueReplacer, but I have my doubts about it....

makt
Contributor
Forum|alt.badge.img+1
  • Author
  • Contributor
  • November 18, 2014
Just tried RasterCellValueReplacer, if I input 'nan' into the parameters, the output is a blank raster, so I don't think it is meant to replace a nan value. 

takashi
Celebrity
  • November 18, 2014

It seems that "nan" is treated internally as a numeric value smaller than any valid value when comparing values.

Try the RasterCellValueReplacer with this setting:

Replace Values <=: -32767

New Value: -32767


makt
Contributor
Forum|alt.badge.img+1
  • Author
  • Contributor
  • November 19, 2014
much more efficient !

 

thanks to you both

takashi
Celebrity
  • June 16, 2019
takashi wrote:

It seems that "nan" is treated internally as a numeric value smaller than any valid value when comparing values.

Try the RasterCellValueReplacer with this setting:

Replace Values <=: -32767

New Value: -32767

An application. This workflow removes every "nan" point from the source point cloud feature.


pdorio
Contributor
Forum|alt.badge.img+8
  • Contributor
  • September 17, 2024

By me works well with raster with NaN nan or -nan Nodata value:

  1. RasterPropertyExtractor
  2. PointCloudCombiner with options: Extract NoData = No

  3. NumericRasterizer, set Cell Spacing and extent with the value extracted with RasterPropertyExtractor. Set your nodata value, example -9999

     


ekkischeffler
Contributor
Forum|alt.badge.img+6

I’ve just tried this in FME 2025.1 but there doesn’t seem to be a real solution to this. I tried (various combinations of):

  • RasterCellValueReplacer (using the <= approach)
  • RasterBandNodataRemover
  • RasterExpressionEvaluator: @if(A[0]==nan,999,A[0])
  • RasterExpressionEvaluator: @if(A[0]<=-99,999,A[0])
  • RasterExpressionEvaluator: @if(@isnodata(A[0]),999,A[0])
  • RasterExpressionEvaluator: @if(@isnodata(A[0])==1,999,A[0])
  • RasterBandNodataSetter: Replace Cell Values - Yes

None of the above seems to handle the nan values. As a workaround I’ve tried:

  • RasterCellCoercer: Extract Nodata Values - No: this still extracts nan-cells! Need to combine this with a Tester afterwards to remove band values < -9999 (or similar)
  • PointCloudCombiner: Extract Nodata - No: this works

Both workarounds add a lot of unnecessary processing, especially with large raster files, and they would require rebuilding a raster if required.

 

The only other option I can see is manipulating the raster geometry via a PythonCaller.

 

Have I missed something - any other suggestions?


jkr_wrk
Influencer
Forum|alt.badge.img+35
  • July 25, 2025

But what are the real values of the rastercell in binary? This could give a hint in the solution.


ekkischeffler
Contributor
Forum|alt.badge.img+6

@jkr_wrk the IMG raster was created with -999 as nodata value and defined as such.


jkr_wrk
Influencer
Forum|alt.badge.img+35
  • July 28, 2025

And where does the NaN come from?

The cell values are numeric/floating. Setting a value to -999 is done on the cell value and calling -999 NoData is done in the 'metadata’.

If you convert your service to a raster and click on a location that had a nan value does it appear as -999 or NoData or does it appear as some other value?

I probably just don’t understand the problem fully, so could be dumb questions.


ekkischeffler
Contributor
Forum|alt.badge.img+6

@jkr_wrk thanks, I probably should have been clearer. No dumb questions!

The raster is being read directly via the ERDAS IMG reader. When I read the raster, the values in question come through as nan and do display as nan in the data inspector. I will need to manage the nodata values, ideally without conversion to vectors.

I do know that the original nodata value was -999 when the raster was written as IMG, plus the nodata value shows as -999 in the ArcPro raster metadata as well.

I was hoping the IMG reader would allow controlling the way nodata is being reproduced but I can’t see a relevant parameter there.


jkr_wrk
Influencer
Forum|alt.badge.img+35
  • July 30, 2025

Did you try the nodata remover?


ekkischeffler
Contributor
Forum|alt.badge.img+6

Yes, as per my post above. 


jkr_wrk
Influencer
Forum|alt.badge.img+35
  • July 31, 2025

I can’t think of any other solutions at this moment. Could you supply a small sample data? And your current not working transformers? Maybe someone else has an revelation when looking at the not working sample.


virtualcitymatt
Celebrity
Forum|alt.badge.img+45

Are you able to extract all cells which are >=0 OR <=0? I would expect this should not include NaN?


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings