在任意位置绘制图像
我想将图像添加到绘图中。我可以使用 image 函数成功地将图像放置在 [0 1] 范围内,但我希望能够将其绘制在另一个位置。这是一个例子:
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)
这创建了一个位于原点的小地图,我想让它跨越我选择的范围(实际上它是实际的纬度/经度)。
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).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 image() 的 x 和 y 参数。请注意 image(x) 如何适用于矩阵,或由 $x 和 $y 向量以及 $z 矩阵组成的列表,但您也可以显式传入 image(x = xvec, y = yvec, z = zmat) 。
因此,粗略地说(您需要检查您是否想要单元格中心 [dim(z)] 还是单元格角 [dim(z)+1])
另外,请阅读 ?image - 它确实解释了这一点。
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.
另请查看教学演示包中的 subplot 函数,或与 my.symbols 一起使用的 ms.image(也在教学演示中)。
Also look at the subplot function in the TeachingDemos package, or ms.image for use with my.symbols (also in TeachingDemos).