Project

General

Profile

« Previous | Next » 

Revision 6b3c8869

Added by Benoit Parmentier about 9 years ago

adding match extent option to mosaicing

View differences:

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/09/2015            
7
#MODIFIED ON: 11/10/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
......
589 589

  
590 590
    if(algorithm=="python"){
591 591
      
592
      if(match_extent==TRUE){
593
        
594
        #If using R, it is necessary to match extent firt
595
        lf_files <- unlist(list_weights)
596

  
597
        ##Maching resolution is probably only necessary for the r mosaic function
598
        #Modify later to take into account option R or python...
599
        list_param_raster_match <- list(lf_files,rast_ref,file_format,python_bin,out_suffix,out_dir)
600
        names(list_param_raster_match) <- c("lf_files","rast_ref","file_format","python_bin","out_suffix","out_dir_str")
601

  
602
        #undebug(raster_match)
603
        #r_test <- raster_match(1,list_param_raster_match)
604
        #r_test <- raster(raster_match(1,list_param_raster_match))
605

  
606
        list_weights_m <- mclapply(1:length(lf_files),FUN=raster_match,list_param=list_param_raster_match,mc.preschedule=FALSE,mc.cores = num_cores)                           
592 607

  
608
        lf_files <- unlist(list_weights_prod)
609
        list_param_raster_match <- list(lf_files,rast_ref,file_format,python_bin,out_suffix,out_dir)
610
        names(list_param_raster_match) <- c("lf_files","rast_ref","file_format","python_bin","out_suffix","out_dir_str")
593 611

  
612
        #num_cores <-11
613
        list_weights_prod_m <- mclapply(1:length(lf_files),FUN=raster_match,list_param=list_param_raster_match,mc.preschedule=FALSE,mc.cores = num_cores)                           
614

  
615
      }else{
616
        list_weights_m <- list_weights
617
        list_weights_prod_m <- list_weights_prod 
618
      }
619
      
594 620
      #The file to do the merge is /nobackupp6/aguzman4/climateLayers/sharedCode/gdal_merge_sum.py. Sample call below.
595 621
      #python /nobackupp6/aguzman4/climateLayers/sharedCode/gdal_merge_sum.py --config GDAL_CACHEMAX=1500 --overwrite=TRUE -o  outputname.tif --optfile input.txt
596 622
      #lf_day_to_mosaic <- list_weights_m
......
607 633
      #writeLines(unlist(list_weights_m),con=filename_list_mosaics_weights_m) #weights files to mosaic 
608 634
      #writeLines(unlist(list_weights_prod_m),con=filename_list_mosaics_prod_weights_m) #prod weights files to mosaic
609 635
      
610
      writeLines(unlist(list_weights),con=filename_list_mosaics_weights_m) #weights files to mosaic 
611
      writeLines(unlist(list_weights_prod),con=filename_list_mosaics_prod_weights_m) #prod weights files to mosaic
636
      writeLines(unlist(list_weights_m),con=filename_list_mosaics_weights_m) #weights files to mosaic 
637
      writeLines(unlist(list_weights_prod_m),con=filename_list_mosaics_prod_weights_m) #prod weights files to mosaic
612 638

  
613 639
      #out_mosaic_name_weights_m <- r_weights_sum_raster_name <- file.path(out_dir,paste("r_weights_sum_m_",mosaic_method,"_weighted_mean_",out_suffix,".tif",sep=""))
614 640
      #out_mosaic_name_prod_weights_m <- r_weights_sum_raster_name <- file.path(out_dir,paste("r_prod_weights_sum_m_",mosaic_method,"_weighted_mean_",out_suffix,".tif",sep=""))
......
630 656
      
631 657
      ## Mosaic sum weights...
632 658
      #input_file <- filename_list_mosaics_weights_m
659
      
633 660
      module_path <- mosaic_python #this should be a parameter for the function...
634 661

  
635 662
      #python /nobackupp6/aguzman4/climateLayers/sharedCode/gdal_merge_sum.py 

Also available in: Unified diff