我正在绘制一个像这样的光栅:
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")
我的文字被添加了。
答案 0 :(得分: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...