Home > ushcn > RGoogleMaps: A snapshot

RGoogleMaps: A snapshot

2010 July 28

Introduction

There is a package for R called RGoogleMaps.

Just feed it coordinates and a zoom level and – voilà – you get back a Google Map image. They are not small – about 500K – 1 meg.

51294_18.png

Code

ushcn_wids=c(6,9,10,7,1,2,1,30,23)
ushcn <- read.fwf("data/ushcn-v2-stations-CO.txt", widths=ushcn_wids, col.names=ushcn_cols, header=F)
ushcn <- ushcn[,c(1,2,3,4,6,8)]
ushcn

range <- nrow(ushcn)
z <- 18
for (i in 1:range) {
    file <- paste("img/",z,"/",ushcn[i,1],"_",z,".png", sep="")
    bb <- qbbox(ushcn[i,2],ushcn[i,3], TYPE = "all", margin = list(m=rep(5,4), TYPE = c("perc", "abs")[1]));
    MyMap <- GetMap.bbox(bb$lonR, bb$latR,destfile = file, maptype = "satellite", zoom=z)
}

Results

Some are easier to find than others …

52281_18.png

Advertisements
  1. 2010 July 28 at 3:13 pm

    Identifying the exact station location will be the hard part. I imagine some images (e.g. your bottom one) will be pretty ambiguous, if not completely off in the case of slightly incorrect lat/lon coords.

  1. 2010 October 26 at 9:25 pm
Comments are closed.