Displaying 1 result from an estimated 1 matches for "gcentroid".
Did you mean:
centroid
2011 Jul 09
1
SpatialPolygonsDataFrame holes problem
...library(rgeos)
india <- readShapeSpatial("india_state.shp")
#Some states are made up of more than one polygon.
#State names are in the NAME column of the dataframe
india at data
plot(india[india$NAME == "Tamil Nadu",], col = 1:8)
#Extract centroid for a State (this works):
gCentroid(india[india$NAME == "Tamil Nadu",])
#Error arises for this State:
gCentroid(india[india$NAME == "Gujarat",])
#Error says:
#Error in createPolygonsComment(p) :
#rgeos_PolyCreateComment: orphaned hole, cannot find containing polygon for hole at index 2
#Code ends
I don't...