Revision ba522425
Added by Adam Wilson almost 11 years ago
climate/research/cloud/MOD09/ee/ee_compile.R | ||
---|---|---|
51 | 51 |
### add boundaries to file list to remove problematic pixels at high latitudes |
52 | 52 |
## these boundaries were later added to the earth engine script, so if it is re-run this is not necessary |
53 | 53 |
#xmin,xmax,ymin,ymax |
54 |
mextent=list(
|
|
54 |
mextent=rbind.data.frame(
|
|
55 | 55 |
"01"=c(-180,-90,180,73.5),# |
56 | 56 |
"02"=c(-180,-90,180,84), # |
57 | 57 |
"03"=c(-180,-90,180,90), |
... | ... | |
65 | 65 |
"11"=c(-180,-90,180,77), |
66 | 66 |
"12"=c(-180,-90,180,69) |
67 | 67 |
) |
68 |
colnames(mextent)=c("xmin","ymin","xmax","ymax") |
|
68 | 69 |
|
69 | 70 |
## project to sinusoidal |
70 | 71 |
proj="'+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs'" |
71 | 72 |
|
72 |
mextentsin=lapply(mextent,function(x) c(project(t(x[1:2]),sub("'","",proj)),project(t(x[3:4]),sub("'","",proj)))) |
|
73 |
mextentsin=data.frame(t(apply(mextent,1,function(x) c(project(t(x[1:2]),sub("'","",proj)),project(t(x[3:4]),sub("'","",proj)))))) |
|
74 |
colnames(mextentsin)=c("xmin","ymin","xmax","ymax") |
|
75 |
mextentsin$xmin=project(t(c(-180,0)),sub("'","",proj))[1] |
|
76 |
mextentsin$xmax=project(t(c(180,0)),sub("'","",proj))[1] |
|
73 | 77 |
|
74 | 78 |
## Loop over data to mosaic tifs, compress, and add metadata |
75 | 79 |
foreach(i=1:nrow(jobs)) %dopar% { |
... | ... | |
93 | 97 |
if(!rerun&file.exists(ttif)) return(NA) |
94 | 98 |
## build VRT to merge tiles |
95 | 99 |
## include subseting using mextentsin object created above to ensure cropping of problematic values |
96 |
system(paste("gdalbuildvrt -b 1 -b 2 -te ",paste(round(mextentsin[[cm]]),collapse=" ")," -srcnodata -32768 -vrtnodata 32767 ",tvrt," ",paste(df$path[df$month==m&df$sensor==s],collapse=" ")))
|
|
100 |
system(paste("gdalbuildvrt -b 1 -b 2 -te ",paste(mextentsin[m,],collapse=" ")," -srcnodata -32768 -vrtnodata 32767 ",tvrt," ",paste(df$path[df$month==m&df$sensor==s],collapse=" ")))
|
|
97 | 101 |
## Merge to geotif in temporary directory |
98 | 102 |
## specify sourc projection because it gets it slightly wrong by default |
99 | 103 |
ops=paste("-multi -of vrt --config GDAL_CACHEMAX 500 -wm 500 -wo NUM_THREADS:10 -srcnodata 32767 -dstnodata 32767 -s_srs ",proj," -t_srs 'EPSG:4326' ", |
Also available in: Unified diff
updating ee_compile