Sum of rasters is incorrect

1257
9
Jump to solution
05-06-2013 12:28 PM
JeffWells
New Contributor
I am attempting to sum multiple rasters - the extent of each raster is the same and I have set NoData to equal 0.  Each raster sums individually to 1; thus, when I add two rasters together, the sum of the resulting raster should be equal to 2.  However, the sum of the resulting raster is less than 2 (it varies depending on which rasters are combined, but it typically sums to between 1.70 and 1.95).  I get the same result when using weighted sums, cell statistics, raster calculator, and the sum tool.  Any thoughts or ideas would be greatly appreciated.
Thanks,
Jeff
0 Kudos
1 Solution

Accepted Solutions
EricRice
Esri Regular Contributor
If I have understood you, if you add all the cells up in a single grid then it should be exactly 1? Well I've not seen this! I went into the symbology tab > classified and clicked on classify to have a look at the SUM, none of them added up precisely to 1.


The classification statistics box on the Classification  dialog (on the classified renderer) are an estimate. Not all of the  values are used when the input is floating point.  It would be too slow.  If you want to have  more accurate stats in this dialog you can follow the steps outlined in  one of our knowledge base documents.

HowTo:  Compute the histogram with all the unique values, when using the classified renderer

Best,
Eric

View solution in original post

0 Kudos
9 Replies
DavidMartin
Occasional Contributor II
What tool are you using?

Normally, the sum of a number of rasters results in a new raster, with each cell value being the sum of the values for that cell within the input rasters. You appear to be looking at a summary statistic for the whole output raster. Is this the mean? Or the median?

Differing cell sizes in the input rasters could perhaps contribute to your issue??
0 Kudos
DuncanHornby
MVP Notable Contributor
Jeff,

Sounds like the source of your problem could be a spatial alignment issue? You say your grids are the same extents but are they different coordinate systems? If not reproject the grid that is different so they are all the same. Also set SnapRaster environment setting to your master grid.

Duncan
0 Kudos
JeffWells
New Contributor
David and Duncan,
  Thank you for replying.  David, in answer to your question about what tool I am using, I have tried weighted sums, cell statistics, raster calculator, and the sum tool, and each gives me the same result.  What I am trying to achieve is exactly what you described: "the sum of a number of rasters results in a new raster, with each cell value being the sum of the values for that cell within the input rasters."  The cell size is the same for every raster (1000 x 1000, in this case meters).

Duncan, thanks for your suggestion.  To see if this was the issue, I reprojected several rasters and set the snap raster environment setting, but after summing the rasters with weighted sums, the end result was the same as before. 

Attached are three rasters if either of you feel like you have time to take a look at them.  I am relatively new to GIS, so let me know if it would easier if I attached an ArcMap document with these rasters already added instead.

Thanks,
Jeff
0 Kudos
DuncanHornby
MVP Notable Contributor
Jeff,

Just looked at your sample data on a machine without spatial analyst so I can't test the cell statistics tool. I did notice that your raster format is floating point. So the error you are seeing is caused by the computer not being able to store the number precisely. Your mean values are very small.

If I have understood you, if you add all the cells up in a single grid then it should be exactly 1? Well I've not seen this! I went into the symbology tab > classified and clicked on classify to have a look at the SUM, none of them added up precisely to 1.

This is where the issue lies. That's why none of the examples you see in Help are floating point... 😉

Duncan
0 Kudos
JeffWells
New Contributor
Duncan,
  Thanks again for responding.  The reason the rasters do not add up to exactly 1 is due to the fact that the values in the cells are very small.  Our goal was to have the rasters add up to exactly 1, but instead at this point we settled for where they are currently at (which although it is not exactly 1, it is very close). 
  The question still remains that when two rasters are summed, why the resulting raster does not sum to a number closer to 2.  Because the individual rasters do not sum to exactly 1, the resulting raster would not sum to exactly 2 but it should be very close (e.g. between 1.98 and 2.01), but instead the resulting rasters are not close to 2.   Do you think this is a result of the computer not being able to store the precise cell values?  Even if this were the case, I would think that the resulting raster would sum to something closer to 2?
Thanks,
Jeff
0 Kudos
EricRice
Esri Regular Contributor
Jeff,

How are you determining what the SUM of an individual raster is?  Are you doing it the way Duncan was...by looking at the classification statistics window?  As a side note, you need to include the 'info' directory associated with these GRIDS you uploaded.  Without you sending that, the data you posted is basically corrupted. 

Best,
Eric
0 Kudos
EricRice
Esri Regular Contributor
If I have understood you, if you add all the cells up in a single grid then it should be exactly 1? Well I've not seen this! I went into the symbology tab > classified and clicked on classify to have a look at the SUM, none of them added up precisely to 1.


The classification statistics box on the Classification  dialog (on the classified renderer) are an estimate. Not all of the  values are used when the input is floating point.  It would be too slow.  If you want to have  more accurate stats in this dialog you can follow the steps outlined in  one of our knowledge base documents.

HowTo:  Compute the histogram with all the unique values, when using the classified renderer

Best,
Eric
0 Kudos
JeffWells
New Contributor
Eric,
  Your last post and link seems to have solved the problem.  Once I changed the registry, I was able to alter each raster using the times tool so that it summed to exactly 1.  From there, when two of the rasters were combined using the weighted sums tool, the resulting raster summed to exactly 2. 
Thank you very much for your help,
Jeff
0 Kudos
DanPatterson_Retired
MVP Emeritus
check cell size
0 Kudos