I have a list with 4 objects, each object is a data frame. The data frame is the coordinate matrix of each polygon. I would like calculate the total area of the 4 polygons and then draw the voronoi tessellation. Here is my workflow, first, I convert the data frame within the list to polygon:
Region_HE_srl <- lapply(Region_HE,FUN= function(x) Polygon(x))
Then, I create the SpatialPolygons object:
Region_HE_sp <- SpatialPolygons(list(Polygons(Region_HE_srl,length(Region_HE))))
area <- gArea(Region_HE_sp, byid = TRUE)
Normally, when there is only 1 polygon within the SpatialPolygon object, this function works fine, but now as there are 4 polygons, an error occurs:
Error in createPolygonsComment(p) : rgeos_PolyCreateComment: orphaned hole, cannot find containing polygon for hole at index 1
Same thing when I applied the voronoi.polygons function from 'SDraw' package.
voronoi.tess <- SDraw::voronoi.polygons(pts_ppp, Region_HE_sp)
The error occurs again. As the package claimed that the bounding polygon parameter should be a spatialpolygons object, I cannot figure out why this error happened.