Romain Francois wrote:
Hi,

You also might want to check R4X:

# install.packages("R4X", repos="http://R-Forge.R-project.org";)
require( "R4X" )
x <- xml("http://code.google.com/apis/kml/documentation/KML_Samples.kml";)
coords <- x["////Polygon///coordinates/#" ]
data <- sapply( strsplit( coords, "(,|\\s+)" ), as.numeric )

Romain

With a bit more formatting :

# install.packages("R4X", repos="http://R-Forge.R-project.org";)
require( "R4X" )
x <- xml("http://code.google.com/apis/kml/documentation/KML_Samples.kml";)
coords <- x["////Polygon///coordinates/#" ]
data <- lapply( strsplit( coords, "(,|\\s+)" ), function(.){
 out <- matrix( as.numeric(.), ncol = 3, byrow = TRUE )
 colnames( out ) <- c("longitude", "lattitude", "altitude" )
 out
})
names( data ) <- x["//Placemark/name/#" ]

Romain

--
Romain Francois
Independent R Consultant
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr

______________________________________________
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.

Reply via email to