Find a shipping vessel's ports based on location data
7 次查看(过去 30 天)
显示 更早的评论
I have the location data (lattitudes and longitudes) for a shipping vessel for a month. Using the data, I am able to plot the route of the vessel in MATLAB, and even calculate the distace the vessel has travelled in that time. The code for that has been attached below. LAT_final and LON_final are the lattitude and longitude vectors.
What I also want to do using the same data is identify the ports for the vessel. The thought process for that is a place where the lattitude and longitude co-ordinates do not change (or show a very small change) for an extended period can be identified as a port. Once identified, I want to designate a small circle (let's say 250 meters) around it as Port A, then move on to the next part and identify the next as Port B. Would that be possible? What should I look to do?
Thank you!
%plotting the vessel's route based on location data
geo = geoplayer(40.38,-79.847,'basemap','satellite','zoomLevel',5);
plotRoute(geo,LAT_final,LON_final,'LineWidth',2)
%setting units to meters using the World Geodetic System of 1984
wgs84 = wgs84Ellipsoid("m");
%finding the distance in meters
lat=length(LAT_final);
for mm=1:1:lat-1
d(mm)=distance(LAT_final(mm),LON_final(mm),LAT_final(mm+1),LON_final(mm+1), wgs84);
end
2 个评论
Star Strider
2023-4-3
‘The code for that has been attached below.’
So now all that’s missing are the data.
采纳的回答
Chunru
2023-4-4
编辑:Chunru
2023-4-5
One way is to look at the change of position (using gradient) and set a threshold.
websave("lat.mat", "https://www.mathworks.com/matlabcentral/answers/uploaded_files/1344449/LAT_final.mat")
websave("lon.mat", "https://www.mathworks.com/matlabcentral/answers/uploaded_files/1344454/LON_final.mat");
load("lat.mat"); load("lon.mat");
% gradient
glat = gradient(LAT_final);
glon = gradient(LON_final);
idx = (glat.^2 + glon.^2) < 0.000001 ; % adjust this threshold
plot(LON_final, LAT_final)
hold on;
plot(LON_final(idx), LAT_final(idx), 'ro')
lon_p = LON_final(idx); lat_p = LAT_final(idx); % position of potential port
[idx, c] = kmeans([lon_p lat_p], 3);
plot(c(:, 1), c(:, 2), 'g^', 'MarkerFaceColor', 'g')
% The port position: lon lat
c
3 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graph and Network Algorithms 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!