[R] ggmap (or ggplot2 with mapping question)

David Winsemius dwinsemius at comcast.net
Sat Dec 27 03:12:03 CET 2014


> On Dec 26, 2014, at 4:51 PM, Roy Mendelssohn - NOAA Federal <roy.mendelssohn at noaa.gov> wrote:
> 
> Thanks.  The map specs are  stored in myMap, it can be displayed just by typing at the prompt:
> 
> myMap
> 

No. As I said before, all I see when I enter myMap at the console prompt is a set of RGB values displayed, not as a graphic item but rather as a character matrix with [1:78,1:1280]-entries. 

…. omitted a thousand lines of output

 [76,] "#384435" "#3B4A38" "#485242" "#384435" "#243223" "#243223"
  [77,] "#424C3D" "#3B4A38" "#424C3D" "#3B4A38" "#2E3C2E" "#243223"
  [78,] "#424C3D" "#3B4A38" "#3B4A38" "#384435" "#324432" "#2E3C2E"
 [ reached getOption("max.print") -- omitted 1202 rows ]

Kind of a PITA.

— 
David.


> 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