### File created on 2008-10-29 ### Code in public domain ### Questions and suggestions can be addressed to: francois.michonneau@gmail.com ### 'table2kml' take a tab delimited file which contains 3 columns: # 1: Station name # 2: latitude # 3: longitude ### and creates a really basic KML file which can be opened in Google Earth table2kml <- function(tableFile, outFile) { coord <- read.table(file=tableFile, header=T, fill=T, stringsAsFactors = FALSE) o <- file(outFile, "w") cat("", "", "", file=o, sep="\n") for(i in 1:nrow(coord)) { if(any(is.na(coord[i,]))) next cat(" ", "\n", " ", coord[i,1], "", "\n", " ", "\n", " ", coord[i,3], ",", coord[i,2], ",0", "\n", " ", "\n", " \n", file=o, sep="") } cat(" \n ", file=o) close(o) cat("File", outFile, "successfully created in:", getwd(), "\n") invisible() }