RGoogleMaps Axes

I can not find the documentation for the following problem that I have with 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(1L, 2L, 3L, 4L, 5L))
# 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))

When I run this on my computer, the horizontal axis ranges from 300 W to 60E, but the ticks between them are not linearly spaced (300 W, 200 W, 100 W, 0, 100 E, 160 W, 60 W). In addition, the vertical axis moves linearly from 300S to 300N. It seems that no matter what data I submit for the data, the axes are always labeled that way.

My question is:
1. Does this problem occur on other machines using this code?
2. Does anyone have an explanation?
and
3. Can someone suggest a way to get the correct axis labels (if they are "wrong", but maybe I'm misinterpreting the plot somehow!)?

.

+3
1
  • @Andrie, . axes = TRUE degAxis(), PlotOnStaticMap(), x y , axTicks(). degAxis() , , rGoogleMaps , . 640 x 640 -300, -200, -100, 0,100, 200, 300 E-W N-S. 300W, 200W, 100W, 0, 100E, 160W, 60W, degreeLabelsEW(), degAxis(), , , [-180, 180], 180 (, 200 20 , .. 160 ). , N, S W .

  • , MyMap:

    PlotOnStaticMap(MyMap, lat = datas$LAT, lon = datas$LON, 
                    axes = FALSE, mar = rep(4.5, 4))
    
    # x-axis
    xrange <- MyMap$BBOX$ur[2] - MyMap$BBOX$ll[2]
    xticklength <- xrange / (length(axTicks(1)) - 1)
    xticklabs <- seq(MyMap$BBOX$ll[2], MyMap$BBOX$ur[2], xticklength)
    xticklabs <- parse(text = paste(sprintf('%.2f', abs(xticklabs)), 
        ifelse(xticklabs < 0, '*degree*W', '*degree*E'), sep=''))
    axis(1, at=axTicks(1), xticklabs, cex.axis=0.8)
    
    # y-axis
    yrange <- MyMap$BBOX$ur[1] - MyMap$BBOX$ll[1]
    yticklength <- yrange / (length(axTicks(2)) - 1)
    yticklabs <- seq(MyMap$BBOX$ll[1], MyMap$BBOX$ur[1], yticklength)
    yticklabs <- parse(text = paste(sprintf('%.2f', abs(yticklabs)), 
        ifelse(yticklabs < 0, '*degree*S', '*degree*N'), sep=''))
    axis(2, at=axTicks(2), yticklabs, cex.axis=0.8, las=1)
    
+1

All Articles