Revision 03e4ccb0
Added by Benoit Parmentier almost 9 years ago
climate/research/oregon/interpolation/global_run_scalingup_mosaicing_function.R | ||
---|---|---|
4 | 4 |
#Different options to explore mosaicing are tested. This script only contains functions. |
5 | 5 |
#AUTHOR: Benoit Parmentier |
6 | 6 |
#CREATED ON: 04/14/2015 |
7 |
#MODIFIED ON: 11/10/2015
|
|
7 |
#MODIFIED ON: 11/12/2015
|
|
8 | 8 |
#Version: 1 |
9 | 9 |
#PROJECT: Environmental Layers project |
10 | 10 |
#COMMENTS: first commit of function script to test mosaicing using 1500x4500km and other tiles |
... | ... | |
192 | 192 |
|
193 | 193 |
#### end of function |
194 | 194 |
|
195 |
mosaic_python_merge <- function(module_path,module_name,input_file,out_mosaic_name){ |
|
195 |
mosaic_python_merge <- function(NA_flag_val,module_path,module_name,input_file,out_mosaic_name){
|
|
196 | 196 |
#out_mosaic_name <- r_weights_sum_raster_name <- file.path(out_dir,paste("r_weights_sum_m_",method_str,"_weighted_mean_",out_suffix,".tif",sep="")) |
197 | 197 |
cmd_str <- paste("python", file.path(module_path,module_name), |
198 | 198 |
"--config GDAL_CACHEMAX=1500", |
199 | 199 |
"--overwrite=TRUE", |
200 | 200 |
paste("-o",out_mosaic_name,sep=" "), |
201 |
paste("--optfile", input_file,sep=" ")) |
|
201 |
paste("--optfile", input_file,sep=" "), |
|
202 |
paste("-n",NA_flag_val,sep=" ")) |
|
202 | 203 |
system(cmd_str) |
203 | 204 |
#list(out_mosaic_name,cmd_str) |
204 | 205 |
mosaic_python_merge_obj <- list(out_mosaic_name,cmd_str) |
... | ... | |
665 | 666 |
# module_name="gdal_merge_sum.py", |
666 | 667 |
# input_file=filename_list_mosaics_weights_m, |
667 | 668 |
# out_mosaic_name=out_mosaic_name_weights_m) |
668 |
mosaic_weights_obj <- mosaic_python_merge(module_path=mosaic_python, |
|
669 |
module_name="gdal_merge_sum.py", |
|
670 |
input_file=filename_list_mosaics_weights_m, |
|
671 |
out_mosaic_name=out_mosaic_name_weights_m) |
|
669 |
#mosaic_python_merge <- function(NA_flag_val,module_path,module_name,input_file,out_mosaic_name){ |
|
670 |
mosaic_weights_obj <- mosaic_python_merge(NA_flag_val=NA_flag_val, |
|
671 |
module_path=mosaic_python, |
|
672 |
module_name="gdal_merge_sum.py", |
|
673 |
input_file=filename_list_mosaics_weights_m, |
|
674 |
out_mosaic_name=out_mosaic_name_weights_m) |
|
672 | 675 |
r_weights_sum_raster_name <- mosaic_weights_obj$out_mosaic_name |
673 | 676 |
cmd_str1 <- mosaic_weights_obj$cmd_str |
674 | 677 |
#r_prod_sum_raster_name <- mosaic_python_merge(module_path=mosaic_python, |
... | ... | |
676 | 679 |
# input_file=filename_list_mosaics_prod_weights_m, |
677 | 680 |
# out_mosaic_name=out_mosaic_name_prod_weights_m) |
678 | 681 |
|
679 |
mosaic_prod_weights_obj <- mosaic_python_merge(module_path=mosaic_python, |
|
680 |
module_name="gdal_merge_sum.py", |
|
681 |
input_file=filename_list_mosaics_prod_weights_m, |
|
682 |
out_mosaic_name=out_mosaic_name_prod_weights_m) |
|
682 |
mosaic_prod_weights_obj <- mosaic_python_merge(NA_flag_val=NA_flag_val, |
|
683 |
module_path=mosaic_python, |
|
684 |
module_name="gdal_merge_sum.py", |
|
685 |
input_file=filename_list_mosaics_prod_weights_m, |
|
686 |
out_mosaic_name=out_mosaic_name_prod_weights_m) |
|
683 | 687 |
r_prod_sum_raster_name <- mosaic_prod_weights_obj$out_mosaic_name |
684 | 688 |
cmd_str2 <- mosaic_prod_weights_obj$cmd_str |
685 | 689 |
#write out python command used for mosaicing |
... | ... | |
1033 | 1037 |
col_mfrow <- 1 |
1034 | 1038 |
row_mfrow <- 1 |
1035 | 1039 |
|
1036 |
# png(filename=paste("Figure10_clim_world_mosaics_day_","_",date_proc,"_",tile_size,"_",out_suffix,".png",sep=""), |
|
1037 |
# width=col_mfrow*res_pix,height=row_mfrow*res_pix) |
|
1040 |
# png(filename=paste("Figure10_clim_world_mosaics_day_","_",date_proc,"_",tile_size,"_",out_suffix,".png",sep=""),
|
|
1041 |
# width=col_mfrow*res_pix,height=row_mfrow*res_pix)
|
|
1038 | 1042 |
png_filename <- paste(prefix_str,"_",date_proc,"_","_",out_suffix_str,".png",sep="") |
1039 | 1043 |
png(filename=png_filename , |
1040 | 1044 |
width=col_mfrow*res_pix,height=row_mfrow*res_pix) |
... | ... | |
1044 | 1048 |
|
1045 | 1049 |
return(png_filename) |
1046 | 1050 |
} |
1047 |
|
|
1048 |
|
|
1049 |
|
|
1050 | 1051 |
##################### END OF SCRIPT ###################### |
1051 |
|
Also available in: Unified diff
modifying python merge mosaicing option