I have obtained shapefiles for Indian states from here: http://www.maptell.com/index.php?option=com_remository&Itemid=159&func=fileinfo&filecatid=115&parent=category
Problem: I want to extract centroid coordinates for each State, but there is some coding problem with the shapefiles that prevents this. #Code: #After extracting the shapefiles from the india_state.zip file, then: library(maptools) library(sp) 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@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 know my way around SpatialPolygonsDataFrame objects very well, and have no idea how to fix the errant hole. Any help greatly appreciated. Thanks Dan Bebber ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.