2017-02-28 73 views
0

我绘制光栅这样的:文本没有被添加到光栅情节

library(raster) 

raster = raster("C:\\Pathway\\raster.tif") 

plot(raster) 
text(0.4, 0.8, "text") 

但不加我的文字。当我在raster包中使用预加载的光栅时,它可以工作。例如:

plot(raster(volcano)) 
text(0.4, 0.8, "text") 

我的文本被添加。

回答

1

您确定在您的栅格范围内包含(*)c(0.4, 0.8)点吗?当您第一次绘制栅格时,这将设置绘图区域的极限,如果文本的坐标不属于它们,则不会出现...

(*)或不太远

library(raster) 

r = raster(volcano) 

par(mfrow=c(3,1)) 

plot(r) 
text(0.4, 0.8, "text") 

extent(r) = c(1,2,1,2) #Change the extent --> c(0.4,0.8) is quite far away 
plot(r) 
text(0.4, 0.8, "text") # does NOT appear... 

plot(r) 
text(1.4, 1.8, "text") # Back in the plot region --> does indeed appear 
text(0.8, 1.5, "Close enough") # Does also appear... 

enter image description here