Project

General

Profile

« Previous | Next » 

Revision 1a5cea73

Added by Benoit Parmentier over 8 years ago

add query function to select stations from given sets of points with lat and long for assessment

View differences:

climate/research/oregon/interpolation/global_product_assessment_part1_functions.R
518 518
  return(obj_sub_sampling)
519 519
}
520 520

  
521
query_for_station_lat_long <- function(point_val,df_points_spdf,step_x=0.25,step_y=0.25){
522
  #make this function better using gbuffer later!!!, works for now 
523
  #Improve: circular query + random within it
524
  y_val <- point_val[2]
525
  x_val <- point_val[1]
526
  
527
  y_val_tmp <- y_val + step_y
528
  if(x_val>0){
529
    x_val_tmp <- x_val - step_x
530
  }else{
531
    x_val_tmp <- x_val + step_x
532
  }
533

  
534

  
535
  test_df <- subset(df_points_spdf,(y_val < df_points_spdf$y & df_points_spdf$y < y_val_tmp))
536
  test_df2 <- subset(test_df,(x_val < test_df$x & test_df$x < x_val_tmp))
537
  #plot(test_df2)
538
 if(nrow(test_df2)>0){
539
   df_selected <- test_df2[1,]
540
 }else{
541
   df_selected <- NULL
542
 }
543
 
544
 return(df_selected)
545
}
521 546

  
522 547
############################ END OF SCRIPT ##################################

Also available in: Unified diff