[R] ggmap (or ggplot2 with mapping question)

Roy Mendelssohn - NOAA Federal roy.mendelssohn at noaa.gov
Sat Dec 27 01:51:05 CET 2014


Thanks.  The map specs are  stored in myMap, it can be displayed just by typing at the prompt:

myMap

 Thanks for the geom.rect suggestion.  I will look at that.

-Roy
On Dec 26, 2014, at 4:16 PM, David Winsemius <dwinsemius at comcast.net> wrote:

> 
>> On Dec 26, 2014, at 3:26 PM, Roy Mendelssohn - NOAA Federal <roy.mendelssohn at noaa.gov> wrote:
>> 
>> 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)
>>> 
> 
> All if get is a matrix. No map.
> 
> 
>> 
>> 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)
>> 
> 
> That looks more like a specification for geom.rect than for geom_polygon.
> 
> 
>> 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 eom_polygon.
> 
> If it were used for eom_polygon I would imagine you need to put it in the form pairs (x,y)
> 
> subbox<-list(x=c(-130,-125,-125,-130,-130),y=c( 20,20,25, 25,20))
> 
> Just a guess mind, you.
> 
>> David.
>> 
>> Thanks for any help.
>> 
>> -Roy
>> 
>> 
>> **********************
>> "The contents of this message do not reflect any position of the U.S. Government or NOAA."
>> **********************
>> Roy Mendelssohn
>> Supervisory Operations Research Analyst
>> NOAA/NMFS
> 
> 
> 

**********************
"The contents of this message do not reflect any position of the U.S. Government or NOAA."
**********************
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
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