[R-sig-Geo] Holes in polygons disappear after performing checkPolygonsHoles from maptools

Grigory Alexandrovich alexandrovich at mathematik.uni-marburg.de
Wed Apr 1 20:03:15 CEST 2015


Hello all,

I encountered the following unexpected result using checkPolygonsHoles:

# attach the worldmap as SpatialPolygonsDataFrame from the package maptools
library(sp)
library(maptools)
data(wrld_simpl)

# get a polygon with a hole
shape_with_hole <- wrld_simpl[5,]

# plot it (hole is left white, surrounded by blue color)
plot(shape_with_hole, col = "blue")

# perform checkPolygonsHoles
shape_with_hole at polygons <- lapply(shape_with_hole at polygons, 
checkPolygonsHoles)

# plot again, now holes aren't recognized as such
plot(shape_with_hole, col = "blue")

# and even the original SpatialPolygonsDataFrame object is changed !?
plot(wrld_simpl[5,], col = "blue")

One irritating side effect here is that the original object wrld_simpl 
is also changed. This result looks to me like a bug, or have I missed 
something?



More information about the R-sig-Geo mailing list