Re: Bounding [message #17742 is a reply to message #17704] |
Fri, 12 November 1999 00:00  |
Michael Asten
Messages: 53 Registered: March 1999
|
Member |
|
|
Brian wrote:
> I am looking for some help with interpolating a surface from ungridded
> data points. I have several thousand measurements in a river with
> corresponding latitudes and longitudes for each of the points. I would
> like to make a surface of these data, but have run into a small
> problem. I have been using a combination of TRIANGULATE and TRIGRID to
> grid the data into a surface, however I end up with data being
> interpolated outside the bounds of the river. Is there any way to bound
> the resulting grid to only include data within the river banks?
Ive seen it done very efffectively using a mask on the grid . As I recall
the logic used was like this (pseudo code ).
gridded data is n points in vectors xgrid,ygrid,zgrid
raw data is m points at locations given by vectors xdata,ydata
cell_size is length of edge of grid cell
no_value =-1.e10 ; is a flag value which is ignored when contouring
dmin=fltarr(n)
for i=0,n-1 do begin
d= sqrt( (xgrid(i)-xdata)^2 + (ygrid(i)-ydata))^2 ) ; vector length m
of distances
dmin(i)=min(d)
endfor
b=where(dmin gt cell_size) ; grid points which are too far from any
measurement point
if b[0] ne -1 then zgrid[b]=no_value ; kill them
contour,zgrid,xgrid,ygrid,min_value=-1.e9
end
Ive been meaning to implement it for some time. I'll be interested to know
whether
Ive got the logic right.
Regards,
Michael Asten
|
|
|