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
Star Strider 2023-4-3
The code for that has been attached below.
So now all that’s missing are the data.
Siddharth Gopujkar
Oops.They're uploaded now. The data takes a long time to extract from the publicly available files, so I've only uploaded 9 days worth of data here.

请先登录,再进行评论。

采纳的回答

Chunru
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")
ans = '/users/mss.system.5CcaYj/lat.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
c = 3×2
-84.3503 46.5029 -92.1050 46.7379 -87.4378 41.6744
  3 个评论
Chunru
Chunru 2023-4-5
See the update above where we use kmeans for getting the centre of the clusters.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graph and Network Algorithms 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by