small islands, how to eliminate?

Dave Gerdes dpgerdes at zorro.cecer.army.mil
Fri Oct 23 14:31:40 EDT 1992


> Date: Thu, 22 Oct 92 15:22:14 EDT
> From: mingham at grits.valdosta.peachnet.edu (mingham)
> Message-Id: <9210221922.AA03376 at grits.valdosta.peachnet.edu>
> Sender: lists-owner at max.cecer.army.mil
> Reply-To: grassu-list at max.cecer.army.mil
> Precedence: Bulk
> To: grassu-list at max.cecer.army.mil
> Subject: small islands, how to eliminate?
> Cc: rbrown at grits.valdosta.peachnet.edu
> 
> Does anyone know a method to remove single pixel islands either in cell map or vector map
> ? I'm trying to export a grass file to arc.info and need fewer than 10,000
> polygons for it to work.
> Thanks,
> Mary Ingham
> mingham at grits.valdosta.peachnet.edu
> 
> 

Well if the map is a binary 0/1 map, you can use  r.mfilter with the following 
filter:

TITLE     delete islands for binary map
MATRIX    3
1 1 1
1 8 1
1 1 1
DIVISOR   17
TYPE      P


Caveat:  Does not get islands on edge of map for some reason.

I originally had the divisor as 9, but r.mfilter 
rounds up instead of truncating so I had to compensate for it.
If you want to try it, this is my test input map that I used:

north: 10
south: 1
east: 10
west: 1
rows: 9
cols: 9
0 1 0 0 0 0 1 0 1
1 0 1 0 1 0 0 0 0
0 1 0 0 0 0 1 0 0
0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 1 1
0 0 0 1 1 1 0 0 0
0 1 0 1 1 1 0 0 0
0 0 0 1 1 1 0 1 0
1 0 0 0 1 0 0 0 0



--
  Dave Gerdes
  US Army Construction Engineering Research Lab
  Spatial Analysis & Systems Team
  dpgerdes at zorro.cecer.army.mil
  (217) 352-6511 x591



More information about the grass-user mailing list