![]() The whole loop is run in parallel to speed things up. The length of the shortest paths are stored in a three column matrix called "results". p <- transition(r, function(x), 8)ģ) Run a loop to calculate the shortest path between all the ports. Where the first column are the longitude and the second column the latitude respectively.Īpply the transition needed to calculate the shortest path and apply the geo-correction more info on the geo-correction you can find here. Thus you end up with a map where all places that a ship can go equal to 1 and all places where a ship can't go are 99999.Ģ) Save the coordinates of the ports in a matrix named "ports". I first created an empty raster: new 1] <- 99999 The rest of the work I did in R using the packages rgdal, raster and gdistance. ![]() I was faced with the same problem and found a solution.ġ) First you have to create a world map raster with all the parts where a ship can go one value and all the places where it can't go another value.įor this I started with a shape file of all countries borders, added the Suez and Panama canal manually using QGIS.
0 Comments
Leave a Reply. |