Dirty resampling of irregularly spaced point data with GRID_INPUT [message #89222] |
Wed, 06 August 2014 02:02  |
Leo
Messages: 3 Registered: October 2013
|
Junior Member |
|
|
Dear group,
I have a dataset that consists of a large number of point measurements (n=10^6) that were taken along regular grid lines (500m x 500m), with single measurements taken with a spacing of about 0.5m (varying) along these lines.
I want to resample the dataset for interpolation to let's say points that are 25m apart. For now, I abuse GRID_INPUT with a large epsilon to find a subset of points and then do the resampling myself by finding for each measurement the closest one in the subset:
;call grid_input to remove "duplicates"
GRID_INPUT, x, y, z, xr, yr, zr, EPSILON=eps
;generate distance table
n = n_elements(x) & nr=n_elements(xr)
d=sqrt( (rebin(transpose(x),nr,n,/SAMPLE)-rebin(xr,nr,n,/SAMPLE))^2 + $
(rebin(transpose(y),nr,n,/SAMPLE)-rebin(yr,nr,n,/SAMPLE))^2 )
;find closest in the subset
tt=min(d, di, DIMENSION=1)
di=(ARRAY_INDICES(d, di))[0,*]
;step through subset and aggregate
hh=HISTOGRAM(di, REVERSE_INDICES=ri)
xr=FLTARR(nr) & yr=FLTARR(nr) & zr=FLTARR(nr)
for i=0, N_ELEMENTS(hh)-1 do begin
ii=ri[ri[i]:ri[i+1]-1]
xr[i]=median(x[ii])
yr[i]=median(y[ii])
zr[i]=mean(z[ii])
endfor
However, I can't find information about how GRID_INPUT actually chooses the subset and I'd like to control what happens there...
Do you have any suggestions for a different solution? I thought about QHULL or TRIANGULATE to find the neighbors of each measurement, but many points are colinear. Any ideas for a straightforward solution?
Thanks a lot,
Leo
|
|
|