how to average data points in column 3 based on values in columns 1 and 2
3 views (last 30 days)
Show older comments
I have a bunch of single beam data points, about 50k points. I want to interpolate between them in a different bathymetric processing software. The data is a combination of two datasets (different surveys), meaning they were collected at different times, so the problem is the depth is not accurate. One survey is deeper than the other likely because of the tides, however the surveys cover the exact same area but at different approach angles (see picture). So when I plot them I have two sets of track lines that dont match up, when looking at my CSV file I have a lot of points that are very similar but not exact. Ive tried filtering unique values in excel and deleting duplicates, only 14/50000 were exactly the same. My question is how do I average these two surveys? Im honestly not sure where to start and there are probably numerous ways to do this so im getting lost in my research.
My goal is to bring these two surfaces to the same depth, and eventually smooth the lines enough to remove the bumpy surface before exporting the points to my other bathymetric program and finally export a geotiff to GIS. Thanks agian, any help is really appreciated!
I forgot to add an example of the data points:
As you can tell some of these points are extremely close together, what I want to do is find ordered pairs in columns 1 and 2 that are very similar and replace all the corresponding values in column 3 with their average. Hopefully any of this makes sense.
Overview of tracklines:
Zoomed in section showing the difference in depth:
Heres my code to visualize the data:
[D,S] = xlsread("BathyScriptTest.xlsx");
lat = D(:,1);
lon = D(:,2);
dep = D(:,3);
depS = smooth(dep);
figure
plot3(lat, lon, depS, '.')
grid on
view(35,60)
title('Bathy Lines')
2 Comments
Image Analyst
on 6 Mar 2024
You forgot to attach "BathyScriptTest.xlsx" so I didn't pay much attention after that. I'll check back later.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
Accepted Answer
Mathieu NOE
on 6 Mar 2024
hello
as your data seemed to lie in a plane , why not make a plane fit and assume from now the data should belong to that plane ?
use the attached function to run the code
no smoothing required here (I haven't found any added value here - my personnal choice)
code :
[D,S] = xlsread("BathyScriptTest.xlsx");
lat = D(:,1);
lon = D(:,2);
dep = D(:,3);
% remove some outliers
mdep = mean(dep);
ind = abs(dep-mdep)<1;
lat = lat(ind);
lon = lon(ind);
dep = dep(ind);
figure
plot3(lat, lon, dep, '.')
hold on
grid on
view(35,60)
title('Bathy Lines')
%compute the normal to the plane and a point that belongs to the plane
ind = (1:50:numel(lat));
XYZ = [lat(ind) lon(ind) dep(ind)];
[n_1,~,p_1] = affine_fit(XYZ);
%plot the two adjusted planes
[Xf,Yf] = meshgrid(lat(ind),lon(ind));
%fitted plane
Zf = - (n_1(1)/n_1(3)*Xf+n_1(2)/n_1(3)*Yf-dot(n_1,p_1)/n_1(3));
surf(Xf,Yf,Zf,'edgecolor','none','facecolor','red','facealpha',0.25);
zlim([mdep-5 mdep+5]);
figure
depf = - (n_1(1)/n_1(3)*lat+n_1(2)/n_1(3)*lon-dot(n_1,p_1)/n_1(3));
plot3(lat, lon, depf, '.')
hold on
grid on
view(35,60)
title('Bathy Lines')
zlim([mdep-5 mdep+5]);
5 Comments
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!