Skip to content
Prev 6111 / 29559 Next

split SpatialPolygon after unionSpatialPolygons()

On Tue, 14 Jul 2009, pecardoso wrote:

            
Please only use examples that refer to a publically available data set.
Exactly. This creates a rectangular polygon for each raster cell specified 
by grd, then removes all internal boundaries between those raster cells 
with the same value of the index, additionally placing all the separate 
Polygon objects with the same value of the index in a Polygons object. 
No-one has given them IDs, all the function has to work on are the index 
values.

I think that this is the same question that you asked recently, to which I 
replied indicating that you should use labcon() in adehabitat to give a 
separate index to each disconnected cluster with the same index values.

The alternative is to re-format the output SpatialPolygons object to find 
out how many Polygon objects there are in each Polygons object, and then 
to flatten those with more than one - that is make each such Polygon 
object into a singleton Polygons object with a unique ID slot value. It is 
possible, but you will need some knowledge of the way these objects are 
constructed. If you can post a sample image, it may not be too hard, 
either using labcon() or by re-formatting the representation.

Roger