Hi,

I have a SpatialPolygon that I have created through a series of
processing steps. The SP consists of one outer-boundary, with a series
of holes punched in it - think of it as the coastline of an island
with a series of lakes in it. However, I am only interested in the
"external" coastline and don't want the "lakes". How do I best remove
these holes?

Here is what I have tried so far (bufr is the object of interest)

holes <- sapply(bufr@polygons[[1]]@Polygons,slot,"hole")
bufr.hole.free <- bufr
bufr.hole.free@polygons[[1]]@Polygons <-
bufr.hole.free@polygons[[1]]@Polygons[!holes]
bufr.hole.free@polygons[[1]]@plotOrder <-
as.integer(rank(bufr.hole.free@polygons[[1]]@plotOrder[holes]))

However, this fails when I try to use it later with rgeos:

 roi.raw <- gDifference(bufr.hole.free,borders)
Error in RGEOSBinTopoFunc(spgeom1, spgeom2, byid, id, "rgeos_difference") :
  lengths of comment and Polygons slot differ


How should I remove the holes in a manner that maintains the integrity
of the SpatialPolygons class?

Mark

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to