Find a shipping vessel's ports based on location data
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Siddharth Gopujkar
le 3 Avr 2023
Commenté : Siddharth Gopujkar
le 5 Avr 2023
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 commentaires
Star Strider
le 3 Avr 2023
‘The code for that has been attached below.’
So now all that’s missing are the data.
Réponse acceptée
Chunru
le 4 Avr 2023
Modifié(e) : Chunru
le 5 Avr 2023
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 commentaires
Chunru
le 5 Avr 2023
See the update above where we use kmeans for getting the centre of the clusters.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Graph and Network Algorithms dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!