The piece of code given below will read and show image of the file with a legend.
how can I tell R to not take into consideration the values of ,for example -9999 ,or any other values when drawing legend.
conne <- file("C:\\DEM.bin", "rb")
image(t(t(y)),ylim=c(1,0))
image.plot(t(t(y)), add = FALSE, legend.shrink = 0.9,legend.width = 1.2,
legend.mar = NULL, graphics.reset = FALSE, horizontal = FALSE, bigplot = NULL,
smallplot = NULL,legend.only = FALSE,lab.breaks=NULL, axis.args=NULL))
Let’s create a mockup dataset (your dataset is not reproducible):
matrix
mnow contains two values you do not want to plot:The solution is to make them
NA, in which case R will know they are missing values:The
NAvalues are now ignored, and replaced by white pixels, and your image looks normal. If there are multiple values you want to make NA:now all the values in the list are marked as
NA.