SHARE
TWEET

Untitled

a guest Jan 12th, 2017 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. par = list()
  2. par$bank.min.dist = 6 # meters
  3.  
  4. for(i in c(2:length(data$x[ix]))){
  5.  
  6.       # add the actual point
  7.       banks$x[[bank]] = c(banks$x[[bank]], data$x[ix.l][i-1])
  8.       banks$y[[bank]] = c(banks$y[[bank]], data$y[ix.l][i-1])
  9.  
  10.       # calculate distance between consecutive bank points
  11.       cb_dist = ( ( data$x[ix][i] - data$x[ix][i-1] )^2 + ( data$y[ix][i] - data$y[ix][i-1] )^2 ) ^(1/2)
  12.  
  13.       # if distance larger than threshold distance interpolate
  14.       if(cb_dist > par$bank.min.dist){
  15.  
  16.         # calculate number of artificial points
  17.         nr_of_pts = ceiling(cb_dist / par$bank.min.dist)
  18.         ap = ap + nr_of_pts
  19.  
  20.         # add artificial points
  21.         for(ido in c(1: (nr_of_pts-1))){
  22.  
  23.           banks$x[[bank]] = c(banks$x[[bank]], data$x[ix][i-1] + ( ( (data$x[ix][i] - data$x[ix][i-1]) / nr_of_pts ) * ido ) )
  24.           banks$y[[bank]] = c(banks$y[[bank]], data$y[ix][i-1] + ( ( (data$y[ix][i] - data$y[ix][i-1]) / nr_of_pts ) * ido ) )
  25.  
  26.         }
  27.  
  28.       }
  29.  
  30.     }
RAW Paste Data
Pastebin PRO Autumn Special!
Get 40% OFF on Pastebin PRO accounts!
Top