download.file("https://www.dropbox.com/s/t279m5ojners7fl/NR.tif?dl=1",
tf <- tempfile(fileext = ".tif"), mode="wb")
library(raster)
library(tiff)
library(ggplot2)
library(reshape2)
DEM <- readTIFF(tf)
plot(as.raster(DEM))
ggplot(melt(DEM),
aes(value, fill=as.factor(Var3))) +
geom_histogram(position="dodge")
关于您的更新,有如下建议
r <- as.raster(DEM)
tab <- as.data.frame(sort(table(r)))
ggplot(subset(tab, !r %in% c("#F0F0F0", "#000000")),
aes(x=r, y=Freq, fill=I(r))) +
geom_bar(stat="identity") +
theme(axis.text.x = element_text(angle=90))
hist(DEM)
或plot(density(DEM))
。 - maRtin