565
1 INTRODUCTION
For many years navigators have been relying on
charts, pilot books (sailing directions) and other
nautical publications as sources of information for
safe voyage planning. Predefined shipping routes
havebeenusedsince1898,whentheywereused,due
to safety reasons, by passenger ships across the
Atlantic (IMO,
2017). The growth in the number of
ships brought the need to organize maritime traffic,
especially in congested waters where headon
encounters were likely to occur. Traffic Separation
Schemes (TSSs) were adopted, first in the English
Channelandprogressivelyallovertheworld.Other
routing measures have been adopted
to organize
traffic and to aid the navigator when planning a
voyage, such as roundabouts, twoway routes,
recommendedroutes,areastobeavoided,deepwater
routes and precautionary areas. However, in many
navigable waters around the world, the decisions
regardingtheshiproutesarenotconstrainedbythese
routing measures,
and depend largely on the
navigator’s (and ultimately the Master’s) choices.
Moreover,when enteringor leaving ports or during
othercriticalmaritimeoperations,alocalpilotisoften
required. Local pilots are expert shiphandlers with
extensive knowledge of the characteristics of
particular waterways, acting as the ship master’s
advisors.
Inmanycases,pilotshavetheconn(directly
controlling the ship’s manoeuvrability) during some
or all stages of the operation. In this context, the
definitionofreliablesafepathsinareaswheretraffic
flowisnotregulatedand/orwherenavigationerrors
can quickly lead to accidents will reduce the
uncertainty of
each operation, thus increasing the
overallsafetylevelandtheefficiencyofthemaritime
operations. These paths can be identified and
properly characterized by analysing historical
AIS Based Shipping Routes Using the Dijkstra
Algorithm
P.Silveira,A.P.Teixeira&C.GuedesSoares
CentreforMarineTechnologyandOceanEngineering(CENTEC),InstitutoSuperiorTécnico,UniversidadedeLisboa,
Portugal
ABSTRACT: This paper proposes an approach for identifying and characterizing shipping routes using
informationcontainedinAutomaticIdentificationSystemmessagesbroadcastedbyshipsandrecordedbythe
coastalVesselTrafficServicecentre.Theapproachconsistsof
usinghistoricalAutomaticIdentificationSystem
datatobuildagraph,wherenodesarecellsofagridcoveringthegeographicalareabeingstudiedandthe
weightsofdirectionaledgesareinverselyrelatedtoshipmovementsbetweencells.Basedonthisgraph,the
Dijkstra algorithm is used to identify a potential
safe route, assumed to be the most used route by ships
betweentwolocations.Asecondgraphiscreatedsimultaneously,withthesamenodesandedges,butwith
edgeweightsequaltotheaveragespeedoftransitionsbetweencells,thusallowingthedeterminationofthe
average speed profile for any possible
path within the graph. The proposed approach is applied to two
scenarios:anapproachtotheportofLisbonandtheentrythroughthefairwaytoaROROterminalintheport
ofSetubalinPortugal.
http://www.transnav.eu
the International Journal
on Marine Navigation
and Safety of Sea Transportation
Volume 13
Number 3
September 2019
DOI:10.12716/1001.13.03.11
566
AutomaticIdentificationSystem(AIS)datathathave
been collectedover the last years, since AIS became
mandatorytomostcommercialvessels.
AIS data have been used by several authors for
maritime traffic characterization (e.g. Silveira et al.,
2012,Rongetal.,2018), for collisionriskassessment
(e.g.Silveiraetal.,
2013,2015;Rongetal.,2016)and
fordevelopingsimulation modelsofshipnavigation
incongestedwaterways(e.g.Rongetal.,2015a,b).
Several algorithms have been proposed for
characterising maritime traffic routes from historical
AISdata.Inparticular,Pallottaetal.,(2013)proposed
a methodology called Traffic Route Extraction and
Anomaly Detection (TREAD), which automatically
learnsa statisticalmodelformaritimetrafficfromAIS
data in an unsupervised way. Discontinuous events
areclusteredtoformwaypointobjects.Thelinking of
thesewaypointobjectsleadstothecharacterizationof
route objects. Anomalies can be detected by
comparing the found routes with real
time traffic.
This research builds on the work of Vespe, et al.,
(2012), which developed the framework aiming at
automatically learning AIS maritime traffic patterns
using anunsupervised approach that works in real
time. Etienne et al., (2010) proposed a process to
extracttrajectoriesfromdataofmovingobjectsand
to
identify unusual behaviour. The process starts by
storingpositionsinaspatiotemporaldatabase,after
which a zone graph is set up and a cluster of
trajectories of objects following the same itinerary
extracted from the database. Then, a statistical
analysisisperformedtocomparepatternsinorderto
qualify
thebehaviourofamobileobject.Theprocess
wasappliedusingAISdataintheBrestarea.
The present paper explores the use of the well
known Dijkstra’s shortest path algorithm (Dijkstra,
1959) for establishing safe paths of ships based on
historicalAISdata.TheDijkstraalgorithm,aswellas
several improved versions of the original method,
have beenwidely used in different contexts such as
for ship route planning, logistics management, and
manyothersnetworkoptimizationproblemsthatcan
beformulatedasshortestpathproblem(e.g.Jooetal.,
2012; Takashima et al., 2009; Mannarini et al., 2013;
Neumann,2016).
The approach proposed in this paper consists of
using AIS data tobuild two graphs.In the firstone
thenodesofthegrapharecellsofagridcoveringthe
geographical area being studied and the weights of
directional edges are inversely related to ship
movements between cells. The
second graph is
createdwiththesamenodesandedges,butwithedge
weights equal to the average speed of transitions
between cells. Based on these graphs, the Dijkstra
algorithmisusedtoidentifythemostusedrouteby
ships between two locations and the average speed
profileforanypossible
pathwithinthegraph.
The proposed approach is applied to two
scenarios:theapproachtotheportofLisbonfromthe
southboundtrafficlanesofthe“OffCapeRocaTraffic
SeparationScheme”andtheentryofthefairwaytoa
ROROterminalintheportofSetubalinPortugal.
2 SAFEPATHSFROMAISTRAFFICDATA
This section details which information can be
obtained from AIS data and describes the proposed
methodindetail.Someimplementationaspects,such
as grid resolution, ship speed anddata quantity are
discussed.
2.1 AISdata
AIS allows automatic exchange of information
betweenstations(ships
andcoastal),usingVHFradio
waves. There are 27 message types defined in the
International Telecommunication Union (ITU)
recommendation M.13715 (ITU, 2014), and two
classesofshipboardequipment:classA(usedmainly
by commercial vessels) and class B (used mainly by
fishing vessels and pleasure craft). The reporting
intervals
of class A equipment vary between 2
seconds and 10 seconds (depending on the ship’s
speedandrateofturn)iftheshipisnotmooredorat
anchor.Iftheshipstatusismooredoratanchor,the
reporting interval is 3 minutes, unless the speed is
greaterthan3
knots,whichsetsthereportinginterval
to10seconds.Themessagetypesusedinthis study
wereposition reports (messagetype1, 2and 3)and
static and voyage related data (message type 5)
transmitted by class A equipment. Information
contained in position reports includes date/time,
Maritime Mobile Service
Identity (MMSI) number,
navigation state, rate of turn, speed over ground,
position accuracy, latitude, longitude, course over
ground and heading. Staticand voyage relateddata
messages include information on MMSI number,
International Maritime Organization (IMO) number,
ship’s name, destination, Estimated Time of Arrival
(ETA), callsign, type of ship, length, breadth and
draught.AISrecordsusedinthisworkwerecollected
by the Portuguese coastal VTS, between 05/05/2012
and21/06/2013.
2.2 Methoddescription
The proposed method to define safe paths based on
AISrecordsstartsbydecodingmessagetypes1,2,3
and5,transmittedby class Ashipequipment. From
these
data, decoded messages originated from the
geographicalareaunderstudyareselectedforfurther
use. Maximum andminimum latitudes and
longitudesdefinethegeographicalarea.Thenextstep
consistsofdefiningagridwithsquarecells,withcell
side length defined according to the required
resolution.
Thenumberofgridrows
andcolumnsisadjusted
sothatthegridtotallyincludestheareaunderstudy.
Figure 1 shows an example of a grid on a traffic
densitymap, coveringoneof the geographicalareas
selectedforapplicationofthedescribedmethod:the
approachestotheportofLisbon.
567
Figure1.Exampleoftrafficdensitymapwithgrid,TSSand
approachestotheportofLisbon
Oncethegridisdefined, aweighteddirectededge
graphthatrepresentstheshiptrafficiscreated.This
graph may be created using all previously selected
AISmessagesorapplyingfiltersforshiptypeand/or
length.Eachgridcellispotentiallyagraphnode.AIS
messages are processed in the order
they were
received and for each position report (AIS message
types1,2and3)theshippositionismatchedtoagrid
cell.Whenashipchangescell,thefollowingprocess
takesplace:
1 iftheoriginordestinationcellsarenotyetgraph
nodes,thesenodesareadded
tothegraph;
2 if there is no edge connecting the origin and
destinationnodes,anedgeiscreatedwithweight
equal to one, otherwise, the edge weight is
increasedbyone.
When all AIS messages are processed the graph
creation process ends. At this stage, the weight of
each edge
of the graph is the number of times a
transition between the origin and destination cells
occurred.
The Dijkstra (1959) algorithm finds the shortest
path between nodes in a directed graph, where
weights represent distances between nodes (or
vertices). The graph weights must be positive. The
pseudocode(Cormenetal.,
2009)forthiswellknown
algorithm,whichtakesasargumentsadirectedgraph
andasourcenodeorvertex,is:
Inputs:
A
weighted,
directed
graph
G
=
(V,
E),
with
all
edge
weightsnonnegative;asourcevertexs.
foreachvertexv
G.V
v.d=∞
v.π=NIL
s.d=0
S=
Q=G.V
whileQ≠
u=EXTRACT‐MIN(Q)
S=S
{u}
foreachvertexv
G.Adj[u]
ifv.d>u.d+w(u,v)
v.d=u.d+w(u,v)
v.π=u
EXTRACT‐MIN(Q) removes and returns the element of Q
with
the
smallest
weigh
t
Sinceinthiscasetheintentionistofindthe“most
used”route,the edgeweightsmustbe inverted and
allweightsmustremainpositiveinordertoapplythe
algorithm. This transformation is performed in the
followingway:
1
ij max ij
ww w
 (1)
wherew
ijistheweightofthedirectededgebetween
node i and node j and w
max is the maximum edge
weight in the graph. Once the edge weights are
calculated,theDijkstraalgorithmis used tofindthe
mostusedtrajectorybetweenanoriginnodeandany
other node in the graph. However, it may be more
interestingtofindthebestroutebetweenagroup
of
origin cells (origin area) and a group of destination
cells (destination area), because one cell may
representaverysmallgeographicalarea, depending
onthegridresolution.
Regarding the grouping of destination cells and
since the Dijkstra algorithm solution includes the
minimalcostpathfromanorigincelltoany
othercell
in the graph, it is only necessary to choose the best
solutionfromthesetofdestinationcells.
Asforthegroupingoforigincells,anextrastepis
added to the proposed algorithm, which consists of
joining all origin cells that are connected through
edgestonon
origincells,updatingtheedgeweights
ascellsarejoined,untilonlyoneorigincellremains.
Thepathwiththelowestcostisfoundbyapplying
theDijkstraalgorithmonthisnewgraph.
2.3 Pathspeedprofiles
To determinethe speed profile of any possible path
within the previously mentioned graph,
a second
graphiscreatedsimultaneously.Nodesandedgesare
addedasdescribedbefore,thedifferencebeinginthe
weight of the edges, which in this second graph
corresponds to the average Speed Over Ground
(SOG)ofshipswhenchangingcells.Onceasafepath
isdeterminedusingthefirst
graph,thespeedprofile
for that path can be found by retrieving the path’s
edgeweightsonthesecondgraph.
2.4 Implementationaspects:Gridresolution,shipspeed
anddataquantity
Itshouldbenotedthatthechoiceofthegridcellside
lengthnotonly influences theresolutionof the path
obtained, but may also bias the results towards the
pathschosenbyslowerships.
As stated before, class A AIS transmits position
reports every 2 to 10 seconds, depending on ship
speedandrateofturn.Ifthegridcelldimensionsare
smallenoughforfasterships toskipone
ormorecells
intransitionsbetweencells,thepathstakenbyslower
ships end up contributing to more edge weights,
thereforebiasingtheresults.Toavoidthis,cellsidein
nauticalmiles(nm)shouldbechosenaccordingtothe
followingcriterion:
568



3600
fmax
Vkts ri s
cell side nm
s
(2)
where V
fis the estimated speed of faster ship and
ri
maxisthemaximumreportinginterval.
A problem related to the choice of grid cell side
length may occur when the cell dimensions are too
small considering the amount of available AIS data,
which,tothelimit,mayresultinalledgeweightsin
thegraphbeingequaltoone,before
transformation.
Inthiscase,assumingshipshaveequalspeeds,the
algorithm would choose the longer path, for which
thesumofinvertededgeweightsissmaller.
3 APPLICATIONTOPORTAPPROACHES
The process previously described to define the safe
paths is applied to a port approach scenario: the
approachtothe
portofLisbonfromthesouthbound
trafficlanesofthe“OffCapeRocaTSS”.Fourgraphs
arecreated, corresponding tofourdifferentperiodsof
theyear:May2012,August2012,November2012and
February2013.Theparametersforcreatingthegraph
are:
Gridcellside:0.01nauticalmiles;
AISshiptypes:7079(cargoships);
Shiplength:greaterorequalto100m.
Figures2to5showthetrafficdensityforthefour
timeperiodsintherelevantgeographicalarea.Figure
6showsthepathsobtainedforthefourtimeperiods,
using all AIS messages received from
ships with
selectedtypesandlength,as well as thegrid,origin
anddestinationareas.
Figure2.Trafficdensity,May2012
Figure3.Trafficdensity,August2012
Figure4.Trafficdensity,November2012
Figure5.Trafficdensity,February2013
Figure6. Paths obtained from all AIS messages, selected
shiptypesandlength
AlthoughtheMayandFebruarypathsseemtobe
goodcandidatestoasafepathbetweentheoriginand
destination areas, the August and November paths
areclearly sufferingfrom theinfluence of the dense
northboundtrafficheadedtotheTSS.Toremovethis
influence,anewgraphiscreatedfollowing
thesame
process, but this time using only AIS messages
receivedfromshipsthattravelledbetweentheorigin
and destination areas (for the same ship types and
length). Due to the existence of an anchorage in
Cascais, it is possible for some ships to cross the
origin area, proceed to
the anchorage, where they
may stay for any period of time, and then proceed
inside the port of Lisbon, crossing the destination
area. For that reason, all voyages taking more than
700minutes(equivalenttoaminimumaveragespeed
ofabout4.7knots)wereexcluded.Sincetheamount
ofselectedAIS
messageswasmuchsmaller,gridcell
sidewasincreasedto0.05(seesection2.4).Figures7
to10showthetrafficdensityoftheselectedvoyages
from origin to destination area, for the four time
periods.Thegraphparametersare:
Gridcellside:0.05nauticalmiles;
AISship
types:7079(cargoships);
Shiplength:≥100m.
569
Figure 11 shows the paths obtained for the four
time periods, using only voyage selected AIS
messagesreceivedfromshipswithselectedtypesand
length, as well as the grid, origin and destination
areas.
Figure7.Trafficdensity,May2012,selectedvoyages
Figure8.Trafficdensity,August2012,selected voyages
Figure9.Trafficdensity,November2012,selected voyages
Figure10.Trafficdensity,February2013,selectedvoyages
Figure11. Paths obtained from selected AIS messages,
receivedfromshipsboundtoLisbon
4 APPLICATIONTOINPORTROUTES
The proposed approach is now applied to define a
safe path in the port of Setubal, from the fairway
entry to the RORO terminal. The entire available
dataset is used, from May 2012 to June 2013. Only
messagesfromshipsthattravelledbetweenthe
origin
and destination areas in under 300 minutes
(equivalenttoaminimumaveragespeedofabout0.9
knots) are considered, once again to exclude paths
takenbyshipsthatanchorinsidetheportofSetubal
beforeproceedingtotheterminal.Theadoptedgraph
parametersare:
Gridcellside:0.01
nauticalmiles;
AISshiptype:7079(cargoships);
Shiplength:greaterorequalto100meters.
Figure12showsthetrafficdensityas well asthe
originanddestinationareas.Figure13showsthepath
obtainedfortheseparameters.
Figure12. Port of Setubal: traffic density, origin and
destinationareas
Asmentionedbefore,theproposedmethodallows
the determination of the speed profile for the path.
Figure 14 shows the speed profile for the path in
Figure13andthesmoothedprofileusingaSavitsky
Golay filter(Savitzky&Golay, 1964)with order= 1
andframelength=51.
Path
points20and40areshowninFigure13for
reference.Itisinterestingtonoticetheslightincrease
inspeedaroundpathpoint20,rightbeforetheturnis
executed.
570
Figure13.PortofSetubal: path,originanddestinationareas
Figure14. Speed profile and smoothed profile, Setubal
fairwaytoROROterminal
5 CONCLUSIONS
Thepresentpaperhascontributedwithanapproach
foridentifyingtypicalroutesofshipsfromhistorical
AISdata.Ingeneral,afterbeingcertifiedasreliableby
authoritiesand/orexperts,theseroutesderivedfrom
AISdatahavethepotentialofbecomingthereference
for ship’s crews, pilots and Vessel Traffic
Services
(VTS), both in the planning stage and during the
monitoring stage ofa voyage.These pathsmay also
beusedasareferenceinaccidentinvestigationsand
maybecomeanenablerforfutureautonomousvessel
operations.
Theproposedmethodprovedtobeveryeffective
in identifying the most used
path between selected
originanddestinationareas,based on historicalAIS
data,givenparticula rshiptypesanddimensions.The
pathobtainedmaybeconsideredsafebecauseittakes
into account the predominant movements of vessels
with the chosen types and dimensions during a
certaintimeperiod.
The quality of the results
is dependent on the
choiceofthegridcellsizeandontheamountofAIS
messagesavailable.Thesetwofactorsarerelatedwith
eachother,tothepointthatthemethodcanreturnthe
pathofoneparticularvesselifthegridcellsizeistoo
smallforthe
amountofAISmessagesavailable,thus
distorting the overall objective. Therefore, these
parametersmustbe carefullychosen. The methodis
alsousefultoobtainthespeedprofileofaparticular
path.
Whenimplementingthemethod,someunexpected
difficulties arose due to errors in AIS data. Possibly
because of the fact that
the AIS messages were
received by several coastal stations and then
combinedinonefile,somemessagesappearedtobe
outofsync.Insomecases,whenplottingconsecutive
positionsofthesameship,itwaspossibletoobserve
the ship’s position alternating back and forth, thus
introducingfalsetransitions
betweengridcellswhen
building the graph. To eliminate this error it was
necessarytofilterouttheoutofsyncmessages.This
potential problem must be taken into account when
applying the method to data collected by multiple
stations.
ACKNOWLEDGEMENTS
This work has been cofunded by the European Regional
Development Fund (Fundo Europeu de Desenvolvimento
Regional (FEDER) and by the Portuguese Foundation for
Science and Technology (Fundação para a Ciênci a e a
Tecnologia FCT) under project ‘‘Integrated System for
Traffic Monitoring and Maritime Risk Assessment
(MoniRisk)”,n.º028746.
The
authors would like to thank the Portuguese coastal
Vessel Traffic Service (VTS) Control Centre (CCTMC) for
providingtheAISdatausedinthisstudy.
REFERENCES
Cormen, T., Leiserson, C., Rivest, R., &Clifford, S. (2009).
IntroductiontoAlgorithms(3rded.).TheMITPress.
Dijkstra, E. W. (1959). A Note on Two Problems in
Connexion with Graphs. Numerische Mathematik, 1(1),
269–271.http://doi.org/10.1007/BF01386390
Etienne, L., Devogele, T., & Bouju, A. (2010). Spatio
Temporal Trajectory Analysis of Mobile
Objects
FollowingtheSame Itinerary. The International Archives
of the Photogrammetry, Remote Sensing and Spatial
Information Sciences, 38(II), 86–91.
http://doi.org/10.1007/s1126301205948
IMO. (20178). IMO‐Ships’ routeing (2017 Edition).
InternationalMaritimeOrganization.
ITU. (2014). Technical characteristics for an automatic
identificationsystemusingtimedivisionmultipleaccess
intheVHF
maritimemobilefrequencyband,M.13715.
InternationalTelecommunicationUnion.
Joo,S.Y.,Cho,T.J.,Cha,J.M.,Yang,J.H.,Kwon,Y.K.(2012).
An economic ship routing system based on a minimal
dynamiccost path search algorithm. KIPS Trans.
Comput.Commun.Syst.1(2),79–86.
Mannarini G., Coppini G., Oddo P., Pinardi N.
(2013). A
PrototypeofShipRoutingDecisionSupportSystemfor
an Operational Oceanographic Service. TransNav, the
InternationalJournalonMarineNavigationandSafetyofSea
Transportation,Vol. 7, No. 1, doi:10.12716/1001.07.01.06,
pp.5359.
Neumann T. (2016). Vessels Route Planning Problemwith
Uncertain Data. TransNav, the International Journal on
Marine
NavigationandSafetyofSeaTransportation,Vol.10,
No.3,pp.459464,doi:10.12716/1001.10.03.11.
Pallotta, G., Vespe, M., & Bryan, K. (2013). Vessel pattern
knowledge discovery from AIS data: A framework for
571
anomalydetectionand route prediction. Entropy, 15(6),
2218–2245.http://doi.org/10.3390/e15062218.
Rong, H., Teixeira, A.P. and Guedes Soares, C., (2015a).
SimulationandanalysisofmaritimetrafficintheTagus
River Estuary using AIS data, Maritime Technology and
Engineering, Guedes Soares, C. & Santos T.A. (Eds.),
Taylor&FrancisGroup,London,UK,
pp.185194.
Rong, H., Teixeira, A.P. and Guedes Soares, C. (2015b).
EvaluationofnearcollisionsintheTagusRiverEstuary
using a marine traffic simulation model, Scientific
Journals of theMaritime University of Szczecin,43(115),
pp.68–78,(ISSN17338670).
Rong, H., Teixeira, A.P. and Guedes Soares, C.
(2016).
Assessment and characterization of near ship collision
scenariosoff the coast of Portugal. MaritimeTechnology
andEngineering3.GuedesSoares&Santos(Eds.),Taylor
&FrancisGroup,London,871–878.
Rong, H., Teixeira, A.P. and Guedes Soares, C. (2018). A
model for predicting ship destination routes based on
AIS data,
Maritime Transportation and Harvesting of Sea
Resources, Guedes Soares & Teixeira (Eds.), Taylor &
FrancisGroup,London,pp.257264.
Savitzky, A., & Golay, M. J. E. (1964). Smoothing and
Differentiation of Data by Simplified Least Squares
Procedures.AnalyticalChemistry,36(8),1627–1639.
Silveira, P. Teixeira, A.P. and Guedes Soares, C.
(2012).
Analysis of maritime traffic off the coast of Portugal,
Maritime Engineering and Technology, C. Guedes Soares,
Y. Garbatov S. Sutulo T. A. Santos, (Eds.), pp. 3541,
Taylor&FrancisGroup.
Silveira,P.,Teixeira,A.,&GuedesSoares,C.(2013).Useof
AIS Data to Characterise Marine Traffic Patterns
and
ShipCollisionRiskofftheCoastofPortugal.TheJournal
of Navigation,66, 879–898. http://doi.org/10.1017/
S0373463313000519.
Silveira, P., Teixeira, A.P. and Guedes Soares, C. (2015).
Assessment of ship collision estimation methods using
AIS data, Maritime Technology and Engineering, Guedes
Soares,C.&SantosT.A.(Eds.), Taylor&FrancisGroup,
London,UK,pp.195204.
Takashima K., Mezaoui B., Shoji R. (2009). On the Fuel
Saving Operation for Coastal Merchant Ships using
Weather Routing. TransNav, the International Journal on
MarineNavigationandSafetyofSeaTransportation,Vol.3,
No.4,pp.401406.
Vespe, M., Visentini, I., Bryan, K., &
Braca, P. (2012).
Unsupervised learning of maritime traffic patterns for
anomalydetection.9thIETDataFusion&TargetTracking
Conference(DF&TT2012): Algorithms&Applications,14–
14.http://doi.org/10.1049/cp.2012.0414.