Monday 22 January 2018

arcobjects - Filtering a raster by pixel cluster size in ArcGIS?


I have a raster image representing islands in a river (see image) created using the following process:


1) Clip a water surface DEM and watershed DEM by a bounding polygon (waters' edge).


2) Subtract the water surface DEM from the watershed DEM (containing island - i.e. elevation values > waters surface).


3) Apply a conditional so that only values > 0 (above the water surface) are kept. All other values become 'no data'. This produces the following image:


enter image description here



By looking at this image you can generally pick out the large island and couple smaller ones. What I would like to do is only keep these islands and remove single pixels or lines of pixels that are artifacts of the clipping process. Is there a way to accomplish this in ArcObjects/ArcGIS 10?


I am thinking something along the lines of: Only keep a group of pixels if it contains at least a 3x3 window within it that contains values. This should produce only islands 3x3 or larger and remove any long artifact "strings" of pixels.


EDIT: Thanks to @whuber I've come up with the following solution. I'll continue on with step four from where I left off above:


4) Convert the output conditional raster to integer format.


5) Region group the integer raster.


6) Perform a Zonal Geometry analysis based on area.


7) Apply a condition to the raster from Step 3 based on the zonal geometry area. For this example I just used a "VALUE > 1", meaning an area larger than 1m square (given the original raster had a resolution of 30cm.


Here is the resulting raster:


enter image description here



Answer




The morphological operators are designed for this, but I think your idea is better because it can be augmented to capitalize (potentially) on the elevation data.


First, RegionGroup the grid so that each apparent "island" gets separately identified. Use this as a basis for zonal summaries. Among your many options are:




  • If the zonal range of elevations within any island is negligibly small, you probably have an artifact (or a very small island).




  • Compute the 3x3 focal count of the island indicator grid. If the zonal max of that is strictly less than 9, your island is indeed too skinny.





  • Compute the island areas (cell counts). Temporarily shrink all islands by one cell (that's one of the morphological operators). Recompute the island areas. Eliminate those whose areas have changed too much (perhaps a reduction of 75%, or even 100%).




The results of the zonal summaries can be used to identify, and thereby select, the cells to erase. A conditional operation will take care of that final step.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...