[英]Change names of stacked raster data in plot rasterVis package in R
I have the next code: 我有下一个代码:
list_data <- list.files(pattern="*NDVI",full.names=T)
stack my data using: 使用以下命令堆叠我的数据:
data <- stack(list_data)
and the names of layers is: 层的名称是:
> names(data)
[1] "Max_NDVI_2000" "Max_NDVI_2001" "Max_NDVI_2002"
[4] "Max_NDVI_2003" "Max_NDVI_2004" "Max_NDVI_2005"
[7] "Max_NDVI_2006" "Max_NDVI_2007" "Max_NDVI_2008"
[10] "Max_NDVI_2009" "Max_NDVI_2010" "Max_NDVI_2011"
then, i need change names of layer: 2000, 2001, ......, 2011, , I'm using 然后,我需要更改图层的名称:2000、2001,......,2011,
names(data) <- 2000:2011
but I get X2000, X2001 ... 但是我得到了X2000,X2001 ...
> names(data)
[1] "X2000" "X2001" "X2002"
[4] "X2003" "X2004" "X2005"
[7] "X2006" "X2007" "X2008"
[10] "X2009" "X2010" "X2011"
however, if I use a characters the output is correct: 但是,如果我使用字符,则输出正确:
> names(data) <- month.abb
> names(data)
[1] "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug"
[9] "Sep" "Oct" "Nov" "Dec"
How the class of month.abb is character then, then I change 然后,month.abb的班级是怎样的人物,然后我改变
names(data) <- as.character(2000:2011)
but the output does not change. 但输出不会改变。
**then, how I can change the names of layer? **然后,如何更改图层名称? **.
**。
PD: I need change the name for plot my data using the rasterVis package (levelplot function) PD:我需要使用rasterVis包(levelplot函数)更改名称以绘制数据
要更改绘图中的图层名称,可以使用names.attr
:
levelplot(data,par.settings=BuRdTheme(),names.attr=c(as.character(2000:2011)))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.