Reputation: 3577
I am plotting a raster like this:
library(raster)
raster = raster("C:\\Pathway\\raster.tif")
plot(raster)
text(0.4, 0.8, "text")
but my text isn't added. When I use a pre-loaded raster in the raster
package it works. For instance:
plot(raster(volcano))
text(0.4, 0.8, "text")
my text gets added.
Upvotes: 0
Views: 346
Reputation: 2592
Are you sure the point c(0.4, 0.8)
is included(*) in the extent of your raster? When you first plot the raster, this sets the limits of the plot region, and if the coordinates of your text do not belong to them, it won't appear...
(*) or not too far away
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...
Upvotes: 1