[R] RgoogleMaps Axes

Mike Marchywka marchywka at hotmail.com
Wed Jun 8 13:35:28 CEST 2011














----------------------------------------
> Date: Tue, 7 Jun 2011 09:50:10 -0700
> From: egregory2007 at yahoo.com
> To: r-help at r-project.org
> Subject: [R] RgoogleMaps Axes
>
> R Help,
>
>
> I posted a question on StackOverflow yesterday regarding an issue I've been having with the RgoogleMaps packages' displaying of axes. Here is the text of that submission:
> http://stackoverflow.com/questions/6258408/rgooglemaps-axes
>
> "I can't find any documentation of the following problem I'm having with the axis labels in RGoogleMaps:
> library(RgoogleMaps)
> datas <-structure(list(LAT =c(37.875,37.925,37.775,37.875,37.875),
> LON =c(-122.225,-122.225,-122.075,-122.075,-122.025)),
> .Names=c("LAT","LON"),class="data.frame",
> row.names =c(1418L,1419L,1536L,1538L,1578L))
> # Get bounding box.
> boxt <-qbbox(lat =datas$LAT,lon =datas$LON)
> MyMap<-GetMap.bbox(boxt$lonR,boxt$latR,destfile ="Arvin12Map.png",
> maptype ="mobile")
> PlotOnStaticMap(MyMap,lat =datas$LAT,lon =datas$LON,
> axes =TRUE,mar =rep(4,4))
>

I haven't gotten too far as I had to download and install proj4 and rgdal
but I did get a transofrm related warning. Did you get warnings?


> MyMap<-GetMap.bbox(boxt$lonR,boxt$latR,destfile ="Arvin12Map.png",maptype ="m
obile")
[1] "http://maps.google.com/maps/api/staticmap?center=37.85,-122.125&zoom=12&siz
e=640x640&maptype=mobile&format=png32&sensor=true"
Loading required package: rgdal
Loading required package: sp
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 1.8.0, released 2011/01/12
Path to GDAL shared files: /usr/local/share/gdal
Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009
Path to PROJ.4 shared files: (autodetected)
Warning message:
In readGDAL(destfile, silent = TRUE) : GeoTransform values not available
>


> PlotOnStaticMap(MyMap,lat =datas$LAT,lon =datas$LON,
+  axes =TRUE,mar =rep(4,4))
List of 6
 $ lat.center: num 37.8
 $ lon.center: num -122
 $ zoom      : num 12
 $ myTile    : int [1:640, 1:640] 968 853 855 969 1033 888 855 884 888 995 ...
  ..- attr(*, "COL")= chr [1:1132] "#000000" "#020201" "#020202" "#030302" ...
  ..- attr(*, "type")= chr "rgb"
 $ BBOX      :List of 2
  ..$ ll: num [1, 1:2] 37.8 -122.2
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr "Y"
  .. .. ..$ : chr [1:2] "lat" "lon"
  ..$ ur: num [1, 1:2] 37.9 -122
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr "Y"
  .. .. ..$ : chr [1:2] "lat" "lon"
 $ url       : chr "google"
NULL
[1] -291.2711  291.2711
[1] -276.5158  276.7972



> When I run this on my computer the horizontal axis ranges from 300W to 60E, but the ticks in between aren't linearly spaced (300W, 200W, 100W, 0, 100E, 160W, 60W). Also, the vertical axis moves linearly from 300S to 300N. It seems that no matter what data I supply for datas, the axes are always labeled this way.
> My question is:
> 1. Does this problem occur on other machines using this code?
> 2. Does anyone have an explanation for it?
> and
> 3. Can anybody suggest a way to get the correct axes labels (assuming these are "incorrect", but maybe i'm somehow misinterpreting the plot!)?
> Thank you for your time."
>
> There has been no answer other than that I ought to contact the package maintainer. Since it would be nice to have a publicly displayed solution, I opted to post here first before doing so. Does anyone have any insight to share?
> Thank you very much for your time,
>
> -Erik Gregory
> CSU Sacramento, Mathematics
> Student Assistant, California Environmental Protection Agency
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code. 		 	   		  


More information about the R-help mailing list