shows a static map which is a png
file.
If I do have a coordinate which lies between the coordinates of this static map file, then how should I plot that point on this map (which is basically a png)?
EDIT:
I would be doing it offline. Can't use the maps API. Will save that map as a PNG, then I have to plot the points.
Answer
The way to do this in R
is as follows: http://cran.r-project.org/web/packages/RgoogleMaps/RgoogleMaps.pdf
library (RgoogleMaps)
png (filename = "plotted.png", width=480, height=480)
lat = c(40.702147,40.718217,40.711614)
lon = c(-74.012318,-74.015794,-73.998284)
center = c(mean(lat), mean(lon))
zoom <- min (MaxZoom (range(lat), range(lon)))
MyMap <- GetMap (center = center,
zoom = zoom,
markers = '&40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc',
destfile = 'original.png');
tmp <- PlotOnStaticMap (MyMap,
lat = c(40.702147, 40.711614, 40.718217),
lon = c(-74.015794,-74.012318,-73.998284),
cex = 1.5,
pch = 20,
col = c('red', 'blue', 'green'),
add = F)
dev.off()
To compile the above R
code in C++
, R
has provided a package named RInside
:
http://dirk.eddelbuettel.com/code/rinside.html
No comments:
Post a Comment