Revision 865457d6
Added by Benoit Parmentier over 9 years ago
climate/research/oregon/interpolation/global_run_scalingup_mosaicing.R | ||
---|---|---|
5 | 5 |
#Analyses, figures, tables and data are also produced in the script. |
6 | 6 |
#AUTHOR: Benoit Parmentier |
7 | 7 |
#CREATED ON: 04/14/2015 |
8 |
#MODIFIED ON: 05/18/2015
|
|
8 |
#MODIFIED ON: 05/25/2015
|
|
9 | 9 |
#Version: 4 |
10 | 10 |
#PROJECT: Environmental Layers project |
11 | 11 |
#COMMENTS: analyses for run 10 global analyses,all regions 1500x4500km and other tiles |
... | ... | |
81 | 81 |
|
82 | 82 |
lf <- list_param$lf |
83 | 83 |
df_centroids <- list_param$df_points |
84 |
feature_raster <- list_param$feature_raster |
|
85 |
use_edge <- list_param$use_edge |
|
84 | 86 |
out_dir_str <- list_param$out_dir_str |
85 | 87 |
|
86 | 88 |
####### START SCRIPT ##### |
... | ... | |
90 | 92 |
set1f <- function(x){rep(NA, x)} |
91 | 93 |
r_init <- init(r1, fun=set1f) |
92 | 94 |
|
93 |
cell_ID <- cellFromXY(r_init,xy=df_centroids[i,]) |
|
94 |
r_init[cell_ID] <- df_centroids$ID[i] |
|
95 |
if(!is.null(df_centroids)){ |
|
96 |
cell_ID <- cellFromXY(r_init,xy=df_centroids[i,]) |
|
97 |
r_init[cell_ID] <- df_centroids$ID[i] |
|
98 |
} |
|
99 |
|
|
100 |
if(!is.null(feature_raster)){ |
|
101 |
cell_ID <- cellFromXY(r_init,xy=df_centroids[i,]) |
|
102 |
r_init[cell_ID] <- df_centroids$ID[i] |
|
103 |
} |
|
95 | 104 |
|
96 | 105 |
#change here to distance from edges... |
106 |
|
|
107 |
#if(use_edge==T){ |
|
108 |
# n_col <- ncol(r_init) |
|
109 |
# n_row <- nrow(r_init) |
|
110 |
# |
|
111 |
# #xfrom |
|
112 |
# r_init[1,1:n_col] <- 1 |
|
113 |
# r_init[n_row,1:n_col] <- 1 |
|
114 |
# r_init[1:n_row,1] <- 1 |
|
115 |
# r_init[1:n_row,n_col] <- 1 |
|
116 |
|
|
117 |
#} too slow |
|
118 |
|
|
119 |
#plot(r_init) |
|
97 | 120 |
r_dist <- distance(r_init) |
98 | 121 |
min_val <- cellStats(r_dist,min) |
99 | 122 |
max_val <- cellStats(r_dist,max) |
... | ... | |
221 | 244 |
|
222 | 245 |
y_var_name <- "dailyTmax" #PARAM1 |
223 | 246 |
interpolation_method <- c("gam_CAI") #PARAM2 |
224 |
out_suffix <- "mosaic_run10_1500x4500_global_analyses_05172015" #PARAM3
|
|
247 |
out_suffix <- "mosaic_run10_1500x4500_global_analyses_05252015" #PARAM3
|
|
225 | 248 |
out_dir <- in_dir #PARAM4 |
226 | 249 |
create_out_dir_param <- TRUE #PARAM 5 |
227 | 250 |
|
... | ... | |
297 | 320 |
num_cores <- 11 |
298 | 321 |
|
299 | 322 |
#debug(create_weights_fun) |
300 |
#weights_obj <- create_weights_fun(1,list_param=list_param_create_weights)
|
|
323 |
weights_obj <- create_weights_fun(1,list_param=list_param_create_weights) |
|
301 | 324 |
|
302 | 325 |
#This is the function creating the weights by tile. Distance from the centroids needs to be change from distance to |
303 | 326 |
#the edges...can use rows and columsn to set edges to 1 and 0 for the others. |
Also available in: Unified diff
adding distance from edge options with R