0

I have a set of rasters which I want to calculate mean of them,these rasters has some NoDate values,I have two approaches first using this code in raster calculator I interpolate them

Con(IsNull("raster"), FocalStatistics("raster", NbrRectangle(5,5, "CELL"), "MEAN"), "raster")

Anyway this must work.But when I run it no changes happens.even by changing window size to 20 px nothing changes.

another approach is setting nodata values to 0 but It will affect on average results. Another one I think I can do is ignore NoData values while avraging but for example when I have 4 rasters and one of them has NoData so in avrage it should devide into 3 not 4.

Anyway.Which one is better?any why I can not make first approach work?

  • Use cell statistics tool MEAN on your list of rasters – FelixIP Mar 19 '15 at 8:21
  • Your first approach works. Just checkd it using copy&paste to arcgis 10.2.1 and it created a fixed raster, averaging the neighbours of NoData cells. Can you give a snapshot of your raster with the NoData cells? – dof1985 Mar 19 '15 at 8:57
  • @dof1985 I dobel chacked and found my raster had 2 bands and because of that it does not work.now first aproach works.but it changed the min and max values – Majid Hojati Mar 19 '15 at 9:50
  • @MajidHojati, it is peciuliar; in my attempt it didn't alter min-max values, and it shouldn't. Is it possible that it is realted to the fact you have 2-bands? You might wish to extract the relevant band to a one-band raster extract band – dof1985 Mar 19 '15 at 10:36
  • 1
    @dof1985 What you have said make scene but why they have changed?I'll run it again and see where is my mistake..thank you – Majid Hojati Mar 21 '15 at 19:07
1

Use zonal statistics as table. Create a raster (with all values == 0) or a polygon feature either to the extent of the raster you wish to calculate statistics for.

Than apply the Zonal statistics as table with the new "mask" as the zones layer, the raster as the value layer, and set ALL as the statistics type. You can use batch processing to operate once for all rasters.

An example below, were mask is a mask raster, and the values come from a DEM. Example

1

Your first option does not change anything because, if any cell is NoData in Focal operations, then the result is also NoData. See the documentation. If that is your preferred approach (and you'll know best what appropriate depending on the nature of your data), you could set the Ignore NoData option. This will ignore all NoData cells in the neighbourhood but also, if the cell itself is NoData, it will set it to the mean of the neighbourhood as desired and avoid the issue of skewing the results by using zeros.

I would probably do this in two steps so I could inspect the output of the Focal mean operation first and if it makes sense, then do the conditional operation on my original data and the output of the focal mean (unless you must automate the process).

  • The first approach works – dof1985 Mar 19 '15 at 8:56
  • In the first approach I have added 'DATA' in case of ignoring NoData values.I got that from documentation – Majid Hojati Mar 19 '15 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.