Skip to content
Prev 11852 / 29559 Next

Converting Spatial Polygons to data frame for krige.conv

Hi Ben,

do you want the coordinates of all the vertices of your polygons?
Have a look at ?geometry. But this doesn't take you down to a mere list of coordinates. There might 
be a more elegant way, but you can try that little function to achieve this:

     asText.SpatialPolygonsDataFrame <- function(obj){
         coords <- matrix(double(), ncol=3)
         for (Polygons in obj at polygons){
             for (Polygon in Polygons at Polygons){
                 coords <- rbind(coords,
                     cbind(as.integer(Polygons at ID), Polygon at coords),
                     c(as.integer(Polygons at ID), NA, NA))
                 }
             }
         return(coords)
         }

regards,
Tom

Am 30.05.2011 07:13, schrieb Ben Madin: