Select to view content in your preferred language

Lokking for a Raster Calculator expression

769
5
08-09-2013 06:34 AM
JochenScholtes
Deactivated User
Dear all,

I have a raster layer and want to reclassify one class based on a rule. Unfortunately I can't find commands for the raster calculator and don't know how to implement it.

Basically I want the Raster Calculator to do the following:

If "my-layer" == 0, reclassify it using a majority filter (8 neighbouring cells)...

Has anyone a clue, how one could implement that?

Best regards.

Muenchner
0 Kudos
5 Replies
MarkBoucher
Honored Contributor
I've used the Shift command for this type of thing. In model builder you can automate and trial and error your process.
Tool location: Toolboxes\System Toolboxes\Data Management Tools.tbx\Projections and Transformations\Raster\Shift

Related post for using Shift: http://forums.arcgis.com/threads/75804-surface-angle-in-each-cardinal-direction?p=265962&viewfull=1#...
0 Kudos
Luke_Pinner
MVP Regular Contributor
Use Con and FocalStatistics. Something like:
Con("raster"==0, FocalStatistics("raster", NbrRectangle(3, 3, "CELL"), "MAJORITY"), "raster")
0 Kudos
Luke_Pinner
MVP Regular Contributor
Can't edit my previous post for some reason...? Anyways: the following raster calculator expression is better as it will ensure that 0 values don't get included when the FocalStatistics expression is executed:
Con("raster" == 0, FocalStatistics(SetNull("raster" == 0, "raster"), NbrRectangle(3, 3, "CELL"), "MAJORITY"), "raster")
0 Kudos
JochenScholtes
Deactivated User
Hi all,

sorry for my late response, I was just out of office.

I'll immediately try your versions and report on the outcome.

Best regards
Jochen
0 Kudos
JochenScholtes
Deactivated User
So I did it like this:

Con("target" == 0, FocalStatistics("target", NbrCircle(5, "CELL"), "MAJORITY"), "target")


It removed all pixels having a value of "0" in just 1 step.
Quite comfortable.

Thanks for all your fast answers.

Best regards
Jochen
0 Kudos