2016-10-13 16 views
0

完全なEVI時系列と日付と品質情報を取得する必要があります。 MODISSubsets()を実行した後、粗データは利用可能ですが、MODISSummaries()と同じようにうまく処理されません。MODISToolsの時系列

MODISSummaries()しかし、品質情報を考慮して、時系列を要約統計量に減らします。

粗データから各タイルの時系列を抽出する方法はありますか(下記のデータフレームcrude参照)?これは、各データフレームが1つのタイルを表し、EVI(または何らかの変数)、日付、および品質フラグのデータを保持するデータフレームのリストを返すことができれば偉大である。あなたは

nice <- list(lonX1_latY1=data.frame(date=..., var=..., qual=...), lonX2_latX2=... ) 

のようなものになるだろうか... ...

savedir <- './' 

modis.subset <- data.frame( 
    lat  = 11.3175, 
    long  = 47.1167, 
    end.date = "2016-09-29" 
) 

MODISSubsets(
    LoadDat = modis.subset, 
    Products = "MOD13Q1", 
    Bands  = c("250m_16_days_EVI", "250m_16_days_pixel_reliability"), 
    Size  = c(1,1), 
    StartDate = FALSE, 
    SaveDir = savedir, 
    TimeSeriesLength = 3 
) 

crude <- read.csv("./Lat47.11670Lon11.31750Start2013-01-01End2016-09-29___MOD13Q1.asc", header = FALSE, as.is = TRUE) 

を次の操作を行った後、具体的に

、...?

答えて

0

要するに、ExtractTile()が戻り値MODISTimeSeries()で使用可能であることがわかりませんでした。私の回避策は、ExtractTile()をASCIIファイルの出力と組み合わせて使用​​することに基づいています。ここでは私の目的のために働いています、ダウンロードされたすべてのMODISデータ(この場合はEVI)を含む行列(npixels_lon、npixels_lat、n_timesteps)を含むリストを返します。ピクセル信頼性コードを含む同一次元のマトリックスと、

read_crude_modis <- function(filn, savedir, expand_x, expand_y){ 

    # arguments: 
    # filn: file name of ASCII file holding MODIS "crude" data 
    # savedir: directory, where to look for that file 
    # expand_x : number of pixels to the right and left of centre 
    # expand_y : number of pixels to the top and bottom of centre 

    # MODIS quality flags: 
    # -1 Fill/No Data Not Processed 
    # 0 Good Data Use with confidence 
    # 1 Marginal data Useful, but look at other QA information 
    # 2 Snow/Ice Target covered with snow/ice 
    # 3 Cloudy Target not visible, covered with cloud 

    library(MODISTools) 

    ScaleFactor <- 0.0001 # applied to output variable 
    ndayyear <- 365 

    ## Read dowloaded ASCII file 
    crude <- read.csv(paste(savedir, filn, sep=""), header = FALSE, as.is = TRUE) 
    crude <- rename(crude, c("V1"="nrows", "V2"="ncols", "V3"="modislon_ll", "V4"="modislat_ll", "V5"="dxy_m", "V6"="id", "V7"="MODISprod", "V8"="yeardoy", "V9"="coord", "V10"="MODISprocessdatetime")) 

    ## this is just read to get length of time series and dates 
    tseries <- MODISTimeSeries(savedir, Band = "250m_16_days_EVI") 
    ntsteps <- dim(tseries[[1]])[1] 
    tmp  <- rownames(tseries[[1]]) 
    time  <- data.frame(yr=as.numeric(substr(tmp, start=2, stop=5)), doy=as.numeric(substr(tmp, start=6, stop=8))) 
    time$dates <- as.POSIXlt(as.Date(paste(as.character(time$yr), "-01-01", sep="")) + time$doy - 1) 
    time$yr_dec<- time$yr + (time$doy - 1)/ndayyear 

    ## get number of products for which data is in ascii file (not used) 
    nprod <- dim(crude)[1]/ntsteps 
    if ((dim(crude)[1]/nprod)!=ntsteps) { print("problem") } 

    ## re-arrange data 
    if (dim(crude)[2]==11 && expand_x==0 && expand_y==0){ 
    ## only one pixel downloaded 
    nice_all  <- as.matrix(crude$V11[1:ntsteps], dim(1,1,ntsteps)) * ScaleFactor  ## EVI data 
    nice_qual_flg <- as.matrix(crude$V11[(ntsteps+1):(2*ntsteps)], dim(1,1,ntsteps))  ## pixel reliability data 

    } else if (dim(crude)[2]>11){ 
    ## multiple pixels downloaded 
    # nice <- ExtractTile(Data = tseries, Rows = c(crude$nrows,expand_y), Cols = c(crude$ncols,expand_x), Grid = TRUE) ## > is not working: applying ExtractTile to return of MODISTimeSeries 
    nice_all  <- ExtractTile(Data = crude[1:ntsteps,11:dim(crude)[2]] * ScaleFactor, Rows = c(crude$nrows[1],expand_y), Cols = c(crude$ncols[1],expand_x), Grid = TRUE) 
    nice_qual_flg <- ExtractTile(Data = crude[(ntsteps+1):(2*ntsteps),11:dim(crude)[2]], Rows = c(crude$nrows[1],expand_y), Cols = c(crude$ncols[1],expand_x), Grid = TRUE) 

    } else { 

    print("Not sufficient data downloaded. Adjust expand_x and expand_y.") 

    } 

    ## Clean data for centre pixel: in case quality flag is not '0', use mean of all 8 surrounding pixels 
    if (expand_x==1 && expand_y==1){ 
    nice_centre <- nice_all[2,2,] 
    nice_centre[ which(nice_qual_flg[2,2,]!=0) ] <- apply(nice_all[,,which(nice_qual_flg[2,2,]!=0)], c(3), FUN=mean) 
    } 

    modis <- list(nice_all=nice_all, nice_centre=nice_centre, nice_qual_flg=nice_qual_flg, time=time) 
    return(modis) 

} 
:その品質フラグが0であるか、またはそうでなければその周囲の画素の平均場合と長さのベクトルが中心画素情報を保持n_timesteps