Chris
Chris

Reputation: 2256

Plotting sized squares on Google-maps

I need to plot many squares of different colors on Google-maps, these commands work well:

library(RgoogleMaps)
Map <- GetMap.bbox(bb$lonR, bb$latR, zoom=zoom, maptype="terrain", NEWMAP=TRUE)
tmp <- PlotOnStaticMap(lat=tbl_to_plot$lat, lon=tbl_to_plot$lon, cex=2, pch=15, col=tbl_to_plot$color, MyMap=Map, add=TRUE, NEWMAP=FALSE, FUN=points)

Choosing pch=15 results in the points becoming squares (good). The challenge is that I need each square to be exactly 100x100 meters big, and as the underlying maps can be of different zoom, it needs to be set automatically. I suppose it is the cex-value I should change, but I don't understand what unit it has.

Thanks to all R-users here at Stack Overflow for a fantastic source of help!

Upvotes: 0

Views: 386

Answers (1)

Richie Cotton
Richie Cotton

Reputation: 121077

The PlotOnStaticMap function uses base graphics, in which sizes of points are a little fuzzy. If you need to accurately specify the size of your squares, you need to use a grid-based graphics package (either lattice or ggplot2).

There's a good demo of using RgoogleMaps with ggplot2 here.

Upvotes: 3

Related Questions