| Title: | Calculation of Maritime Distances |
|---|---|
| Description: | Tools for calculating and visualizing maritime distances and routes between geographic points. At its core, it implements a fast Haversine formula implemented in data.table to compute great circle distances across sea regions (i.e. avoiding land mass). The package builds a spatial network graph from port and cluster coordinates and uses a shortest path algorithm to identify optimal maritime routes between origin-destination pairs. For visualization, the package exports maps displaying individual routes, multi-destination networks, or continuous routes through specified waypoints. Utility functions identify the nearest network nodes to arbitrary coordinates and handle the antimeridian discontinuities common in Pacific maritime mapping. The package is particularly suited for analyzing shipping lanes, trade routes, and vessel trajectory data. |
| Authors: | Panayotis Christidis [cre, aut] |
| Maintainer: | Panayotis Christidis <[email protected]> |
| License: | EUPL |
| Version: | 1.1.1 |
| Built: | 2026-10-01 20:18:54 UTC |
| Source: | https://github.com/cran/mardist |
Latitude and longitude of the maritime clusters used in the network.
A data.frame with columns 'cluster', 'latitude', 'longitude'.
Calculates the maritime distance between two geographic points.
distance_route(lon1, lat1, lon2, lat2)distance_route(lon1, lat1, lon2, lat2)
lon1 |
numeric. Longitude of the origin (decimal degrees). |
lat1 |
numeric. Latitude of the origin (decimal degrees). |
lon2 |
numeric. Longitude of the destination (decimal degrees). |
lat2 |
numeric. Latitude of the destination (decimal degrees). |
The distance in nautical miles (numeric).
distance_route(121.48, 31.2198, 79.85, 6.95)distance_route(121.48, 31.2198, 79.85, 6.95)
Computes the great circle distance between two points on the Earth surface using the Haversine formula. The result is returned in the same linear unit as the radius r that you supply (the default is the WGS 84 Earth radius in metres).
dtHaversine(lat_from, lon_from, lat_to, lon_to, r = 6378137)dtHaversine(lat_from, lon_from, lat_to, lon_to, r = 6378137)
lat_from |
numeric. Latitude of the *from* point (decimal degrees). |
lon_from |
numeric. Longitude of the *from* point (decimal degrees). |
lat_to |
numeric. Latitude of the *to* point (decimal degrees). |
lon_to |
numeric. Longitude of the *to* point (decimal degrees). |
r |
numeric. Radius of the sphere used for the calculation. The default value 6378137 is the WGS84 equatorial radius in metres. |
The distance between the two points, expressed in the same unit as r (metres by default).
## Distance between Shanghai (121.48 E, 31.2198 N) and ## Goa (79.85 E, 6.95 N) the value is given in metres. dtHaversine(31.2198, 121.48, 6.95, 79.85)## Distance between Shanghai (121.48 E, 31.2198 N) and ## Goa (79.85 E, 6.95 N) the value is given in metres. dtHaversine(31.2198, 121.48, 6.95, 79.85)
Given a data frame / data.table ('clist') that contains a list of coordinates, the function draws a **leaflet** map with the shortest route line that connects the points in thelist. The function is useful for visualising a full route that passes from specific points (e.g. all vessel port calls during a certain period).
multi_point_route(clist)multi_point_route(clist)
clist |
A data.frame or data.table that must contain **two** columns with the exact names 'longitude' and 'latitude'. Any additional columns are ignored. |
An object of class **'leaflet'** that displays all of the shortest maritime routes contained in 'clist'.
## A multi-port route: routes <- data.frame(cbind( longitude=c(120,122,90,60,30,25,0,8), latitude=c(30,31,40,32,40,34,34,55))) multi_point_route(routes)## A multi-port route: routes <- data.frame(cbind( longitude=c(120,122,90,60,30,25,0,8), latitude=c(30,31,40,32,40,34,34,55))) multi_point_route(routes)
Given a single origin ('lon1', 'lat1') and a data frame / data.table ('clist') that contains destination coordinates, the function draws a **leaflet** map with a separate shortest route line for each destination.
multi_route_map(lon1, lat1, clist)multi_route_map(lon1, lat1, clist)
lon1 |
numeric. Longitude of the origin (decimal degrees). |
lat1 |
numeric. Latitude of the origin (decimal degrees). |
clist |
data.frame or data.table. Must contain columns 'lon' and 'lat'. Additional columns are ignored. |
A 'leaflet' map object displaying all routes.
destinations <- data.frame(lon = c(80, 85), lat = c(7, 10)) multi_route_map(121.48, 31.2198, destinations)destinations <- data.frame(lon = c(80, 85), lat = c(7, 10)) multi_route_map(121.48, 31.2198, destinations)
Given a data frame / data.table ('clist') that contains a collection of origin destination pairs, the function draws a **leaflet** map with a separate shortest route line for each pair. The function is useful for visualising an entire network of maritime connections (e.g. trade routes, shipping lanes, etc.).
multi_route_map_network(clist)multi_route_map_network(clist)
clist |
A data.frame or data.table that must contain **four** columns with the exact names 'longitude.x', 'latitude.x', 'longitude.y' and 'latitude.y'. The “*.x“ columns represent the origins, the “*.y“ columns represent the destinations. Any additional columns are ignored. |
An object of class **'leaflet'** that displays all of the shortest maritime routes contained in 'clist'.
## Two dummy routes: ## from (lon=120, lat=30) to (lon=80, lat=7) ## from (lon=122, lat=31) to (lon=85, lat=10) routes <- data.frame( longitude.x = c(120, 122), latitude.x = c(30, 31), longitude.y = c(80, 85), latitude.y = c(7, 10) ) multi_route_map_network(routes)## Two dummy routes: ## from (lon=120, lat=30) to (lon=80, lat=7) ## from (lon=122, lat=31) to (lon=85, lat=10) routes <- data.frame( longitude.x = c(120, 122), latitude.x = c(30, 31), longitude.y = c(80, 85), latitude.y = c(7, 10) ) multi_route_map_network(routes)
An igraph edge list that describes the global maritime network. The object is a data frame with columns 'cluster', 'lag_cluster', and 'distance' (in metres).
A data.frame with N rows and 3 columns.
JRC
Wrapper that forwards to 'map_route'. It exists only so that the examples can use the short name 'route_map'.
route_map(lon1, lat1, lon2, lat2)route_map(lon1, lat1, lon2, lat2)
lon1 |
longitude of the origin (decimal degrees) |
lat1 |
latitude of the origin (decimal degrees) |
lon2 |
longitude of the destination (decimal degrees) |
lat2 |
latitude of the destination (decimal degrees) |
A 'leaflet' map object.