Revision 21d7e7c5
Added by Adam Wilson about 10 years ago
climate/research/cloud/MOD09/ee/ee_compile.R | ||
---|---|---|
20 | 20 |
### Download files from google drive |
21 | 21 |
## This only works if google-cli is installed and has already been authenticated |
22 | 22 |
download=T |
23 |
if(download) system(paste("google docs get 2014*_g3_* ",datadir,"/mcd09ee",sep=""))
|
|
23 |
if(download) system(paste("google docs get 2014043_g3_* ",datadir,"/mcd09ee",sep=""))
|
|
24 | 24 |
|
25 | 25 |
|
26 | 26 |
## Get list of available files |
... | ... | |
47 | 47 |
rerun=T # set to true to recalculate all dates even if file already exists |
48 | 48 |
|
49 | 49 |
## define month-sensors to process |
50 |
jobs=unique(data.frame(month=df$month,sensor=df$sensor))
|
|
50 |
jobs=unique(data.frame(month=as.numeric(df$month),sensor=df$sensor))
|
|
51 | 51 |
|
52 | 52 |
i=1 |
53 | 53 |
#jobs=jobs[jobs$sensor=="MYD09",] |
... | ... | |
64 | 64 |
s2=sub("GA","",s) |
65 | 65 |
|
66 | 66 |
## Define output and check if it already exists |
67 |
tvrt=paste(tmpfs,"/",s2,"_",sprintf("%02d", m),".vrt",sep="")
|
|
68 |
ttif1=paste(tmpfs,"/",s2,"_",sprintf("%02d", m),".tif",sep="")
|
|
67 |
tvrt=paste(datadir,"/mcd09tif/",s2,"_",sprintf("%02d", m),".vrt",sep="")
|
|
68 |
ttif1=paste(datadir,"/mcd09tif/",s2,"_",sprintf("%02d", m),"_uncompressed.tif",sep="")
|
|
69 | 69 |
ttif2=paste(datadir,"/mcd09tif/",s2,"_",sprintf("%02d", m),".tif",sep="") |
70 | 70 |
|
71 | 71 |
## check if output already exists |
... | ... | |
76 | 76 |
## Merge to geotif in temporary directory |
77 | 77 |
## specify sourc projection because it gts it slightly wrong by default #-ot Int16 -dstnodata -32768 |
78 | 78 |
ops=paste("-s_srs ",proj," -t_srs 'EPSG:4326' -multi -srcnodata -32768 -ot Int16 -dstnodata -32768 -r bilinear -te -180 -90 180 90 -tr 0.008333333333333 -0.008333333333333", |
79 |
"-co BIGTIFF=YES --config GDAL_CACHEMAX 500 -wm 500 -wo NUM_THREADS:10 -co COMPRESS=LZW -co PREDICTOR=2") |
|
79 |
"-co BIGTIFF=YES --config GDAL_CACHEMAX 2000 -wm 2000 -wo NUM_THREADS:10 -co COMPRESS=LZW -co PREDICTOR=2") |
|
80 |
## if file exists, remove it avoid warping into existing file |
|
81 |
if(file.exists(ttif1)) file.remove(ttif1) |
|
82 |
## run the warp |
|
80 | 83 |
system(paste("gdalwarp -overwrite ",ops," ",tvrt," ",ttif1)) |
81 | 84 |
|
82 | 85 |
## Compress file and add metadata tags |
Also available in: Unified diff
Fixed month-sorting bug in ee_compile that resulted in data being attributed to the wrong month