简体   繁体   English

来自phenex软件包的modelNDVI()函数,用于平滑和分析不规则多年时间序列的其他软件包?

[英]modelNDVI() function from phenex package, other package for smoothing and analysing irregular multi-year time series?

I have multiple time series as *.csv files. 我有多个时间序列作为* .csv文件。 They all have a first column for date, and a second column for (ndvi) values. 它们都有第一列用于日期,第二列用于(ndvi)值。 The time series is describes irregular, a few years are missing in between the 30 year time span and also the values are not spaced evenly within each year (which excludes working with class "ts" and a few other from the beginning). 时间序列描述不规则,在30年时间跨度之间缺少几年,并且每年内的值不均匀分布(不包括从“ts”级开始工作和从开始时的其他一些工作)。 Each year in my series has some kind of seasonal amplitude that i would like to fit a function to. 我系列中的每一年都有某种季节性幅度,我想要适合它。
For those familiar with phenology and remote sensing, i would like to basically retrieve the same metrics as what TIMESAT does (for the years containing enough values). 对于那些熟悉物候学和遥感的人,我想基本上获取与TIMESAT相同的度量(对于包含足够多的值的年份)。 I've found the phenex package, including the function modelNDVI(), which I think would do exactly what I am looking for - correcting my values using bise (best index slope extraction) and smoothing with Savitzky-Golay or Assymetric Gaussian. 我找到了phenex软件包,包括函数模型NDVI(),我认为它正是我正在寻找的 - 使用bise(最佳索引斜率提取)修正我的值并使用Savitzky-Golay或Assymetric Gaussian进行平滑。 My data looks basically like this: 我的数据基本上看起来像这样:

head(test)
     system.time_start         X1
3  1985-01-17 01:00:00 0.04546319
6  1985-02-10 01:00:00 0.05106874
7  1985-02-18 01:00:00 0.10060238
8  1985-02-26 01:00:00 0.04757872
9  1985-03-06 01:00:00 0.03484827
11 1985-03-22 01:00:00 0.02705866

...
2357 2015-11-17 01:00:00 0.04524300
2358 2015-11-17 01:00:00 0.04476613
2359 2015-11-25 01:00:00 0.03424461
2360 2015-11-25 01:00:00 0.05062974
2364 2015-12-11 01:00:00 0.09578227
2368 2015-12-27 01:00:00 0.09661864

Clearly modelNDVI() needs a vector, so: 显然,modelNDVI()需要一个向量,因此:
test.vec <- as.vector(test$X1) . test.vec <- as.vector(test$X1)
I've also found out it must be a vector of length [1:365] which is my first problem. 我也发现它必须是长度为[1:365]的向量,这是我的第一个问题。 So I figured i have to convert my vector to another vector that is of the desired length, containing my values and a lot of NA's to be handled by the function. 所以我想我必须将向量转换为具有所需长度的另一个向量,其中包含我的值和该函数要处理的许多NA。
Second problem: 第二个问题:
I would like to model my whole time series, not only a single year (modelNDVI() only accpects year.int as a single observation year as an argument). 我想对我的整个时间序列建模,而不仅限于单个年份(modelNDVI()仅将year.int视为单个观察年作为参数)。 So my question is, does anyone know if I can get modelNDVI() to work with my dataset? 所以我的问题是,有没有人知道我是否可以使用modelNDVI()来处理我的数据集? And if not, can anyone suggest a different way to handle my problem with modeling my irregular multi-year time series? 如果没有,任何人都可以建议一种不同的方式来处理我的问题,建立我的不规则多年时间序列? Any packages, tutorials? 任何包,教程? I'm still relatively new to R and while I was looking for a solution I came accross numerous ways of handling irregular timeseries but none really could solve my problem of ending up with correcting and modeling my data. 我对R还是比较陌生,在寻找解决方案时,我遇到了许多处理不规则时间序列的方法,但是没有一种方法可以解决校正和建模数据的问题。 Thanks for any advice! 谢谢你的建议!

After puzzling over a similar problem, I realized that the NDVI vector needs to be 365/366 days long (as you discovered), but also that it needs to be an NDVI class object. 在思考了类似的问题之后,我意识到NDVI向量需要长达365/366天(如您所见),但是它也必须是NDVI类对象。 Check out ?bise1 for example code. 查看?bise1以获得示例代码。

As for multi-year applications, I can't comment. 至于多年的申请,我无法发表评论。

Ran into this same problem. 遇到同样的问题。 Here is my fix which creates a vector 365 days long and adds the ndvi value for each day i had data based on the ndvi.tiff file (eg 20160131_NDVI.tiff is 31/01/2016 or 31st day of the year) but you can easily modify this if you already have the ndvi values and their respective date of acquisition. 这是我的修复程序,该修复程序创建了一个365天长的向量,并根据ndvi.tiff文件(例如20160131_NDVI.tiff为31/01/2016或一年的31日)添加我每天拥有数据的ndvi值,但是您可以如果您已经具有ndvi值及其各自的获取日期,则可以轻松地对此进行修改。

library(raster)
library(plyr)
library(rgdal)
library(rgeos)
library(phenex)
library(lubridate)

ndvi.list <- list.files(path = ".", pattern = "*ndvi.tif$", ignore.case = TRUE, 
full.names = TRUE, recursive = TRUE)
ndvi.stack <- stack(ndvi.list)
ndvi_values <- matrix(0,0,366)

# find mean ndvi (e.g. within a shapefile boundaries)
ndvi <- extract(ndvi.stack, shapefile, fun=mean, df=TRUE)

#use filenames to retrieve data information from ndvi.tiff files (e.g. mine were 
called 20160210_NDVI.tif)
ndvicols <- names(ndvi.stack)  
ndvicols <- sub("X","",ndvicols) 
ndvicols <- sub("_NDVI","",ndvicols)
dates <- as.Date(ndvicols, format = "%Y%m%d")
doy <- lubridate::yday(dates)  

#create ndvi vector
vec <- rep(0, 365)
ndvi.vals <- as.vector(t(ndvi[,2:ncol(ndvi)]))
vec[doy] <- ndvi.vals

# create NDVI object, apply correction (e.g. BISE) and model values (e.g. Linear interpolation)
ndvi.list <- modelNDVI(ndvi.values=vec,
                    year.int=2016, multipleSeasons=FALSE, correction="bise",
                    method="LinIP", MARGIN=2, doParallel=FALSE, slidingperiod=10)

# create vector of modelled values
vec.mod <- ndvi.list[[1]]@modelledValues

NOTE: for multiple years you'll have to run each year separately and append the data for each subsequent year 注意:对于多年,您必须分别每年运行一次,并在随后的每一年附加数据

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM