Skip to content
Prev 180173 / 398506 Next

plotting a grid with color on a map

dxc13 wrote:
How about the following, which doesn't need a grid at all?

library(maps)
temp <- as.matrix(read.table("time1test.txt"))
xvals <- c(0, 0, 5, 5, 0)
yvals <- c(0, 5, 5, 0, 0)
map("world")
palette(rainbow(50))
for (lat in seq(-90, 85, 5))
   for (lon in seq(-180, 175, 5)) {
     col <- temp[(lat + 95)/5, (lon + 185)/5]
     if (!is.na(col)) polygon(lat + xvals, lon + yvals, col=col, border=NA)
   }
palette("default")

HTH
Ray Brownrigg