# Reclass If/then logic [closed]

Have a binary raster. I would like to remove any 'islands' that are fully surrounded by one of the classes while leaving the 'islands' that are fully surrounded by the other.

If 1 is enveloped by 0, then reclassify to 0. If 0 is enveloped by 1, leave as one.

Essentially a select by location, but for raster. This is super easy in vector - struggling to find a solution in raster. Am I overlooking the obvious?

Platforms of choice are Arc or QGIS.

## closed as too broad by PolyGeo♦Dec 21 '17 at 4:24

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• Could you specify which tools you use? – Lennert De Feyter Dec 21 '17 at 0:36
• What particular GIS software do you wish to ask about? – PolyGeo Dec 21 '17 at 0:37
• Arc, QGIS, Imagine – user71015 Dec 21 '17 at 1:02
• Raster to polygon, fix (you say this is super easy in vector), then polygon to raster. – Michael Stimson Dec 21 '17 at 1:42
• Or you can get away with a combination of raster calculator in Arc toolbox. the following string will get rid of the lonely '1' values. . Con((FocalStatistics("%test.tif%",NbrRectangle(3,3,"CELL"),"SUM")==1) & ("%test.tif%"==1),0,"%test.tif%") To get rid of the 0 values: Con((FocalStatistics("%test.tif%",NbrRectangle(3,3,"CELL"),"SUM")==8) & ("%test.tif%"==0),1,"%test.tif%") – Lennert De Feyter Dec 21 '17 at 1:49