1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
| plotkml <- function(file, projection = "azequalarea" , parameter = NULL, grid = TRUE, info = TRUE,... ){ require(maptools) require(mapproj) require(mapdata) zz <- getKMLcoordinates(file, ignoreAltitude = TRUE) x11(11,9) m <- map('world',proj= projection, parameter = parameter, orient=c(zz[[1]][2], zz[[1]][1], 0), ...) for(i in 1:length(zz)){ if(is.data.frame(zz[[i]])){ if(ncol(zz[[i]]) > 3){ i = i + 1 } } if(is.list(zz[[i]])){ i = i + 1 } if(is.vector(zz[[i]])){ points(mapproject(list(y = zz[[i]][2], x= zz[[i]][1])), pch = "*", cex = 2, col = 2) } if(is.matrix(zz[[i]])){ lines(mapproject(list(y = zz[[i]][,2], x= zz[[i]][,1])), col = "blue", ...) } } if(grid){ map.grid(m, lty = 1, col = "grey") } file1 <- readLines(file) if(title){ daterecord <- file1[grepl("when", file1)] date <- substring(gsub(" ", "", daterecord), 7, 16) type <- file1[grepl("Type:", file1)] stype <- gsub(" ", "", type) typesolar <- substring(stype, 12, regexpr("<br", stype) - 1) title(paste(typesolar, "solar eclipse on", date)) } if(info){ bg <- which(grepl("<li>Magnitude:", file1)) info <- file1[bg:(bg+4)] infosub <- gsub("</li>", "", gsub(" ","",gsub("<li>", "",gsub(" ", "", info)))) text(-1.3, seq(1.4, 1.1, by = -0.1),infosub[1:4]) bg <- min(which(grepl("<name>P1", file1))) sub <- file1[bg:(bg+100)] ind <- min(which(regexpr("<longitude>",sub)>0)) info <- sub[c(ind, ind +1)] info1 <- gsub("de", "de:",gsub("/longitude","",gsub("/latitude", "", gsub("[<->]", "", gsub(" ", "",info))))) information <- c("Partial Eclipse begins:", info1) text(-1.3,seq(-1.1, -1.3, by = -0.1),information) bg <- min(which(grepl("last external", file1))) sub <- file1[bg:(bg+100)] ind <- min(which(regexpr("<longitude>",sub)>0)) info <- sub[c(ind, ind +1)] info1 <- gsub("de", "de:",gsub("/longitude","",gsub("/latitude", "", gsub("[<->]", "", gsub(" ", "",info))))) information <- c("Partial Eclipse ends:", info1) text(1.3,seq(-1.1, -1.3, by = -0.1),information) bg <- min(which(grepl("Greatest Eclipse Point", file1))) sub <- file1[bg:(bg+100)] ind <- min(which(regexpr("<longitude>",sub)>0)) info <- sub[c(ind, ind +1)] info1 <- gsub("de", "de:",gsub("/longitude","",gsub("/latitude", "", gsub("[<->]", "", gsub(" ", "",info))))) information <- c("Greatest Eclipse:", info1) text(1.3,seq(1.3, 1.1, by = -0.1),information) } }
|