I would like to add an image to a plot. I can sucessfully place the image in the range [0 1] using the image function, but I would like to be able to plot it in an alternate location. Here is an example:
require(rgdal)
require(RgoogleMaps)
bb <- qbbox(c(40.702147,40.711614,40.718217),c(-74.015794,-74.012318,-73.998284), TYPE = "all", margin = list(m=rep(5,4), TYPE = c("perc", "abs")[1]));
MyMap <- GetMap.bbox(bb$lonR, bb$latR,destfile = "MyTile3.png", maptype = "satellite")
plot(0:20,0:20)
image(MyMap$myTile,col=attr(MyMap$myTile,"COL"),add=TRUE)
This creates a tiny map located at the origin, I would like to have it span a range of my choosing (In reality it’s actual latitude/longitude).
Use the x and y arguments to image(). Note how image(x) will work for a matrix, or a list composed of $x and $y vectors and $z matrix, but you can also pass in image(x = xvec, y = yvec, z = zmat) explicitly.
So, roughly (you will need to check whether you want cell centres [dim(z)] or cell corners [dim(z)+1])
Also, read ?image – it does explain this.