我正在生成湖泊叶绿素图。我想用蓝色填充湖泊,其中叶绿素浓度非常低,NA值为淡蓝色。我使用的是下面的代码如何区分gplot中的背景颜色和NA值
gplot(Chlorophyll_map_5) + geom_tile(aes(fill=value)) + scale_fill_gradient(low = 'blue', high = 'red', na.value='blue',name="Chl-a (ug/l)",limits=c(0,1000)) + coord_equal()+theme_bw()
这让我对na.value='blue'
这样的情节一样给出:
当我使用na.value='transparent'
我得到这个图片:
如果我改变na.value的颜色,它也会改变背景。有没有办法在不改变背景的情况下用颜色填充湖面?
我的数据的输出:`我的数据的输出:
Formal class 'RasterLayer' [package "raster"] with 12 slots
[email protected] file :Formal class '.RasterFile' [package "raster"] with 13 slots
.. .. [email protected] name : chr "/private/var/folders/68/hm_5ts9x7psb6j3wnb91_bfr0000gn/T/RtmpZ3BLZD/raster/r_tmp_2017-07-18_133827_28365_34843.grd"
.. .. [email protected] datanotation: chr "FLT8S"
.. .. [email protected] byteorder : Named chr "little"
.. .. .. ..- attr(*, "names")= chr "value"
.. .. [email protected] nodatavalue : num -1.7e+308
.. .. [email protected] NAchanged : logi FALSE
.. .. [email protected] nbands : int 1
.. .. [email protected] bandorder : Named chr "BIL"
.. .. .. ..- attr(*, "names")= chr "value"
.. .. [email protected] offset : int 0
.. .. [email protected] toptobottom : logi TRUE
.. .. [email protected] blockrows : int 0
.. .. [email protected] blockcols : int 0
.. .. [email protected] driver : chr "raster"
.. .. [email protected] open : logi FALSE
[email protected] data :Formal class '.SingleLayerData' [package "raster"] with 13 slots
.. .. [email protected] values : logi(0)
.. .. [email protected] offset : num 0
.. .. [email protected] gain : num 1
.. .. [email protected] inmemory : logi FALSE
.. .. [email protected] fromdisk : logi TRUE
.. .. [email protected] isfactor : logi FALSE
.. .. [email protected] attributes: list()
.. .. [email protected] haveminmax: logi TRUE
.. .. [email protected] min : num 0.00335
.. .. [email protected] max : num 3870657
.. .. [email protected] band : int 1
.. .. [email protected] unit : chr ""
.. .. [email protected] names : chr "layer"
[email protected] legend :Formal class '.RasterLegend' [package "raster"] with 5 slots
.. .. [email protected] type : chr(0)
.. .. [email protected] values : logi(0)
.. .. [email protected] color : logi(0)
.. .. [email protected] names : logi(0)
.. .. [email protected] colortable: logi(0)
[email protected] title : chr(0)
[email protected] extent :Formal class 'Extent' [package "raster"] with 4 slots
.. .. [email protected] xmin: num 35.8
.. .. [email protected] xmax: num 36.7
.. .. [email protected] ymin: num 2.4
.. .. [email protected] ymax: num 4.65
[email protected] rotated : logi FALSE
[email protected] rotation:Formal class '.Rotation' [package "raster"] with 2 slots
.. .. [email protected] geotrans: num(0)
.. .. [email protected] transfun:function()
[email protected] ncols : int 3240
[email protected] nrows : int 8321
[email protected] crs :Formal class 'CRS' [package "sp"] with 1 slot
.. .. [email protected] projargs: chr "+proj=longlat +ellps=WGS84 +no_defs"
[email protected] history : list()
[email protected] z : list()
它不会改变我能看到的背景。你的地图数据是什么样的?您可能在整个盒装区域都有NAs。 – troh
我已经下载了Landsat 8 OLI/TIRS图像并在其中应用了回归模型。我将如何摆脱整个盒装区域的NA值并仅保留湖泊?我之前用湖形文件裁剪了图像。 –
你可以显示你的数据的'str'的输出吗? – troh