Message-ID: <0879F172-B5E8-4BAD-A024-1DA1100DBF77@remoteinformation.com.au>
Date: 2011-05-30T16:28:15Z
From: Ben Madin
Subject: Converting Spatial Polygons to data frame for krige.conv
In-Reply-To: <4DE33807.3050909@tum.de>
Thanks Tom,
On 30/05/2011, at 2:24 PM, Tom Gottfried wrote:
> 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)
> }
Perfect. It's where I thought I was going, but it probably would have taken me about two days!
cheers
Ben