r - Holes in polygons disappear after performing checkPolygonsHoles from maptools -


note: @ edzer pebesma's suggestion, question has been crossposted r-sig-geo, here, has received responses.


i encountered following unexpected result using checkpolygonsholes:

# attach worldmap spatialpolygonsdataframe package maptools library(sp) library(maptools) data(wrld_simpl)  # polygon hole shape_with_hole <- wrld_simpl[5,]  # plot (hole left white, surrounded blue color) plot(shape_with_hole, col = "blue")  # perform checkpolygonsholes  shape_with_hole@polygons <- lapply(shape_with_hole@polygons,   checkpolygonsholes)  # plot again, holes aren't recognized such plot(shape_with_hole, col = "blue")  # , original spatialpolygonsdataframe object changed !? plot(wrld_simpl[5,], col = "blue") 

one irritating side effect here original object wrld_simpl changed. result looks me bug, or have missed something?

p.s.: object shape_with_hole edited checkpolygonsholes before, continues behave strange:

# check polygons marked holes. flags still set  # properly, although `plot` function didn't recognize them: sapply(shape_with_hole@polygons[[1]]@polygons, slot, "hole")  [1] false  true  true  true  # load library rgdal reprojection library(rgdal)  # reproject `sptransform`, testing shape_with_hole <- sptransform(shape_with_hole,  crs("+proj=longlat +ellps=wgs84 +datum=wgs84"))  # after reprojection flags set false  sapply(shape_with_hole@polygons[[1]]@polygons, slot, "hole")  [1] false false false false 

this clear report has revealed bug in r package sp, became manifest in r 3.1.x see here more detail. sp 1.1-0, available cran, has fixed this.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -