R光栅情节甚至传说

时间:2018-06-10 03:33:50

标签: r plot raster netcdf4

我尝试使用NetCDF文件使用rasterncdf4包在R中绘制栅格地图。

我的数据范围太大,但几乎我的数据分布在0-2000之间。您可以查看我的数据的直方图:

enter image description here

enter image description here

所以我想绘制一个间隔为200的图,就像seq(0, 2000, 200)一样。 但是当我使用这些间隔时,大于2000的值在绘制图时被R识别为NA。这些大值在绘图时打印为透明。

enter image description here

使用均匀间隔的图:

enter image description here

我试图给情节留出很大的间隔,比如breaks = c(seq(0, 1500, 100), 40000),但情节的传说看起来很难看。

总之,我想要一个偶数间隔和图例的情节。像开放范围,而不是封闭范围。

下图是我通过其他软件实现的理想情节。如何使用R?

解决我的问题

enter image description here

我的代码在这里:

    library(rgdal)
    library(raster)
    library(ncdf4)
    library(rasterVis)
    library(sp)

    ncname <- "output.nc"
    ncdata <- nc_open(ncname)
    bb <- raster(ncname)

    hist(bb)
    hist(bb, xlim = c(0, 2000), breaks = seq(0, 40000, 500))

    plot(bb)
    plot(bb, xlim = c(25, 53), asp = 1.5,  breaks = c(seq(0, 1500, 100), 40000), col = topo.colors(20)) 

    plot(bb, legend.only = FALSE, zlim = c(0, 2000), col = topo.colors(20), asp = 1.5,
         legend.width = 1, legend.shrink = 1.0,
         axis.args = list(at = seq(0, 2000, 100),
         labels = seq(0, 2000, 100)))

0 个答案:

没有答案
相关问题