Spatial Analyst (Raster Calculator): 'focalmean' no more?

10712
14
07-16-2010 11:45 AM
MatthewRobinson
New Contributor
Hi,

I have a simple expression that worked great in the 9.x Raster Calculator to interpolate NoData values, but am having all kinds of trouble in 10:

dem1 = con(isnull([dem0]), focalmean([dem0], rectangle, 3, 3, data), ([dem0]))

Part of the problem is that con, isnull, etc. are now case-sensitive (Con, IsNull), but the most recent error message tells me that 'focalmean' is not recognized.

Any help 'modernizing' this expression would be hugely appreciated. Thanks!

-Matt
0 Kudos
14 Replies
DanPatterson_Retired
MVP Emeritus
if it is indeed case-sensitive, check the online help for the syntax (FocalMean???)
Break the operation into steps using tool in arctoolbox to see if you can get it to work.

also, you last expression  ([dem0]) doesn't need the brackets ()
0 Kudos
MatthewRobinson
New Contributor
Thanks Dan. I checked with the Arc10 Resource Center (URL: http://help.arcgis.com/EN/ArcGISDesktop/10.0/Help/00q8/00q80000006m000000.htm) for help with the syntax and case but unfortunately it's still not working:

Con(IsNull([point2ras]), FOCALMEAN ([point2ras] , RECTANGLE , 3 , 3, data), [point2ras])

When I run the expression with that structure, Spatial Analyst returns an error saying that the name of the input raster is not defined. I inserted "" around the layer name, re-ran it, and got a different error ['expected a raster or layer name']. I've attached a screen-capture of the error messages, for reference.

Any other suggestions?

Thanks,
Matt
0 Kudos
EricRice
Esri Regular Contributor
Hi Matt,

The FocalMean command you're familiar with is not available in the new raster calculator.  The documentation you pointed to is wrong and I will submit a defect to have it changed.  To accomplish this task you need to use FocalStatistics with the mean statistic type within your Con statement.

It should look like this:
xxx= Con(IsNull("point2ras"),FocalStatistics("point2ras",NbrRectangle(3,3),"MEAN"),"point2ras")

Where xxx is my output name and i'm using a 3 x 3 rectangular neighborhood.

You may find this link helpful as it discusses differences between 9.x and 10.
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Comparing_Map_Algebra_between_9_x_and_...

What is Map Algebra (in 10)
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/What_is_Map_Algebra/00p600000002000000...

Let me know if this helps.

Regards,
Eric
0 Kudos
DanPatterson_Retired
MVP Emeritus
this change apparently affects all "focal" statics types, see
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z000000qs000000.htm
for the correct syntax for all types
0 Kudos
MatthewRobinson
New Contributor
Hi Eric and Dan,

Both you guys, thanks so much for your help!! The new expression worked great, and I really appreciate the links to the "What's New" between 9x and 10.

Best,
Matt
0 Kudos
AndyRitchie
Occasional Contributor
How do I submit a "defect"?

The changes made to the Focal Statistics don't even make sense. In addition to reducing the flexibility of the software to users (it's ok if there's more than one way to do something), it makes it harder to type in a simple map algebra statement.

I think this is a great illustration of what's wrong with ESRI's "update" strategy, and why people are repeatedly frustrated and alienated by ESRI every time an update breaks things. I am pretty adaptable, so it's not that big a deal to me, but I am also one of only two people who's been willing to upgrade to 10 in my division so far - and the other one said today that she's switching back.

What was the reason to add the 'Nbr' prefix to every neighborhood shape? Other than adding three more letters to type every time I enter a statement into the raster calculator this seems pointless. I know it's a neighborhood, just like I know that a circle is a circle without having to call it ShapeCircle.

oh, whoops. Is there somewhere I am supposed to put rants?
(this post was useful btw, at least I figured out how to change my syntax)
0 Kudos
JamalNUMAN
Legendary Contributor
it didn't work!!!!

help, please




Thanks Dan. I checked with the Arc10 Resource Center (URL:   http://help.arcgis.com/EN/ArcGISDesktop/10.0/Help/00q8/00q80000006m000000.htm) for help with the syntax and case but unfortunately it's still not working: 

Con(IsNull([point2ras]), FOCALMEAN ([point2ras] , RECTANGLE , 3 , 3, data), [point2ras]) 

When I run the expression with that structure, Spatial Analyst returns an error saying that the name of the input raster is not defined. I inserted "" around the layer name, re-ran it, and got a different error ['expected a raster or layer name']. I've attached a screen-capture of the error messages, for reference. 

Any other suggestions? 

Thanks, 
Matt
----------------------------------------
Jamal Numan
Geomolg Geoportal for Spatial Information
Ramallah, West Bank, Palestine
0 Kudos
EricRice
Esri Regular Contributor
Hi Jamal,

I reviewed your screenshot and you are specifying FOCALMEAN which is not a command in map algebra at 10.0. Please review my earlier post wherein I provide the syntax to use at 10.0.  i.e. FocalStatistics


Regards,
Eric
0 Kudos
JamalNUMAN
Legendary Contributor
Thank you for the answer Eric.

i'm trying to replace the nodata cells with the 3x3 average window but didn't work

please, see the attached images

what might be wrong?

thank you

regards

Jamal


Hi Jamal,

I reviewed your screenshot and you are specifying FOCALMEAN which is not a command in map algebra at 10.0. Please review my earlier post wherein I provide the syntax to use at 10.0.  i.e. FocalStatistics


Regards,
Eric
----------------------------------------
Jamal Numan
Geomolg Geoportal for Spatial Information
Ramallah, West Bank, Palestine
0 Kudos