[R] ggmap (or ggplot2 with mapping question)

Roy Mendelssohn - NOAA Federal roy.mendelssohn at noaa.gov
Sat Dec 27 00:26:16 CET 2014

HI All:

Okay I am feeling particular brain dead today.  i have the following map created so far using ggmap:

> library(ggmap)
> myLocation <- c(-178, -28, -72, 48)
> myMap <- get_map(location=myLocation, source="google", maptype="satellite", crop=FALSE)

I want to color in some lat-lon 5 degree boxes based on some criterion,  and it look like this could be done use geom_polygon if I can figure out how to get the data in the format required for geom_polygon.  To simplify the problem, suppose i have a bounding box:

subbox<-c(-130, 20, -125, 25)

and I want to color that box red on myMap defined above.    To put this in context, I actually have 360 squares which have been clustered by some criteria, and I want to color them all based on the cluster number of the box. but if I can figure out how to do the simple problem above I can  extend it to the more general problem.

Basically the question is how can I get that simple box information into the format required for geom_polygon.

Thanks for any help.


"The contents of this message do not reflect any position of the U.S. Government or NOAA."
Roy Mendelssohn
Supervisory Operations Research Analyst
Environmental Research Division
Southwest Fisheries Science Center
***Note new address and phone***
110 Shaffer Road
Santa Cruz, CA 95060
Phone: (831)-420-3666
Fax: (831) 420-3980
e-mail: Roy.Mendelssohn at noaa.gov www: http://www.pfeg.noaa.gov/

"Old age and treachery will overcome youth and skill."
"From those who have been given much, much will be expected" 
"the arc of the moral universe is long, but it bends toward justice" -MLK Jr.

More information about the R-help mailing list