Skip to content

Table of Contents

georouting.routers.base

GoogleRoute Objects

1
class GoogleRoute()

The class "GoogleRoute" which allows to retrieve information from a route provided as an argument.

The class has the following methods:

  • get_duration(): Returns the duration of the route in seconds.

  • get_distance(): Returns the distance of the route in meters.

  • get_route(): Returns the complete route information.

  • get_route_geopandas(): Returns a GeoDataFrame with information such as distance, duration, and speed of each step in the route.

It is assumed that the polyline module is used for decoding the polyline into a LineString geometry. The GeoDataFrame is created with a specified coordinate reference system (CRS) of "4326".

get_duration

1
def get_duration()

Returns the duration of the route in seconds.

get_distance

1
def get_distance()

Returns the distance of the route in meters.

get_route

1
def get_route()

Returns the complete route information.

get_route_geopandas

1
def get_route_geopandas()

Returns a GeoDataFrame with information such as distance, duration, and speed of each step in the route. It is assumed that the polyline module is used for decoding the polyline into a LineString geometry. The GeoDataFrame is created with a specified coordinate reference system (CRS) of "4326".

BingRoute Objects

1
class BingRoute()

BingRoute class that allows you to extract various information from a route stored in a dictionary. It has the following functions:

  • get_duration(): Returns the travel duration in seconds.
  • get_distance(): Returns the travel distance in meters.
  • get_route(): Returns the entire route in a dictionary.
  • get_route_geopandas(): Returns the route information in a GeoPandas dataframe.

This function extracts the duration and distance information for each leg of the route, creates a list of shapely LineStrings representing the route, and then creates a GeoDataFrame with columns for the duration, distance, and geometry. Additionally, it calculates the speed in meters per second for each leg.

The class is designed to work with data returned by the Bing Maps REST Services API, as the data is stored in a dictionary with a specific structure.

get_duration

1
def get_duration()

get the travel duration in seconds

get_distance

1
def get_distance()

get the travel distance in meters

get_route

1
def get_route()

get the entire route in a dictionary

get_route_geopandas

1
def get_route_geopandas()

This function extracts the duration and distance information for each leg of the route, creates a list of shapely LineStrings representing the route, and then creates a GeoDataFrame with columns for the duration, distance, and geometry. Additionally, it calculates the speed in meters per second for each leg.

Returns the route information in a GeoPandas dataframe.

OSRMRoute Objects

1
class OSRMRoute()

This class represents a route returned by the OpenStreetMap Routing Machine API.

Methods:

  • get_duration() -> float: Returns the duration of the route in seconds.
  • get_distance() -> float: Returns the distance of the route in meters.
  • get_route() -> dict: Returns the full route as a dictionary.
  • get_route_geopandas() -> geopandas.GeoDataFrame: Returns the route as a GeoDataFrame. The GeoDataFrame contains columns for 'duration (s)', 'distance (m)', 'geometry', and 'speed (m/s)'.

get_duration

1
def get_duration()

Get the duration of the route in seconds.

get_distance

1
def get_distance()

Get the distance of the route in meters.

get_route

1
def get_route()

Get the full route information as a dictionary.

get_route_geopandas

1
def get_route_geopandas()

Get the route as a GeoDataFrame. The GeoDataFrame contains columns for 'duration (s)', 'distance (m)', 'geometry', and 'speed (m/s)'.

EsriRoute Objects

1
class EsriRoute()

The EsriRoute class is a class for handling a route obtained from the Esri ArcGIS routing service.

The class has the following methods:

  • get_duration: returns the total travel time of the route.

  • get_distance: returns the total distance of the route in meters.

  • get_route: returns the entire route as a dictionary.

  • get_route_geopandas: raises a NotImplementedError. This method is not yet implemented and will be added in the future.

BaiduRoute Objects

1
class BaiduRoute()

This class represents a route returned by the Baidu Maps Direction API.

Methods:

  • get_duration() -> float: Returns the duration of the route in seconds.
  • get_distance() -> float: Returns the distance of the route in meters.
  • get_route() -> dict: Returns the full route as a dictionary.
  • get_route_geopandas() -> geopandas.GeoDataFrame: Returns the route as a GeoDataFrame.

get_duration

1
def get_duration()

Get the duration of the route in seconds.

get_distance

1
def get_distance()

Get the distance of the route in meters.

get_route

1
def get_route()

Get the full route information as a dictionary.

get_route_geopandas

1
def get_route_geopandas()

Get the route as a GeoDataFrame. The GeoDataFrame contains columns for 'duration (s)', 'distance (m)', 'geometry', and 'speed (m/s)'.

TomTomRoute Objects

1
class TomTomRoute()

This class represents a route returned by the TomTom Routing API.

Methods:

  • get_duration() -> float: Returns the duration of the route in seconds.
  • get_distance() -> float: Returns the distance of the route in meters.
  • get_route() -> dict: Returns the full route as a dictionary.
  • get_route_geopandas() -> geopandas.GeoDataFrame: Returns the route as a GeoDataFrame.

get_duration

1
def get_duration()

Get the duration of the route in seconds.

get_distance

1
def get_distance()

Get the distance of the route in meters.

get_route

1
def get_route()

Get the full route information as a dictionary.

get_route_geopandas

1
def get_route_geopandas()

Get the route as a GeoDataFrame. The GeoDataFrame contains columns for 'duration (s)', 'distance (m)', 'geometry', and 'speed (m/s)'.

MapboxRoute Objects

1
class MapboxRoute()

get_route_geopandas

1
def get_route_geopandas()

Returns a GeoDataFrame with distance, duration, and speed for the route legs.

HereRoute Objects

1
class HereRoute()

get_route_geopandas

1
def get_route_geopandas()

Build a GeoDataFrame from the first route leg's shape coordinates.

ORSRoute Objects

1
class ORSRoute()

OpenRouteService route wrapper.

get_route_geopandas

1
def get_route_geopandas()

Returns a GeoDataFrame with distance, duration, and speed.

Route Objects

1
class Route(object)

A wrapper class that wraps different routing engines' route objects.

It will return a Route object that can be used to get the duration, distance, and route information.

The class has the following methods:

  • get_duration(): Returns the duration of the route in seconds.

  • get_distance(): Returns the distance of the route in meters.

  • get_route(): Returns the complete route information.

  • get_route_geopandas(): Returns a GeoDataFrame with information such as distance, duration, and speed of each step in the route.

__init__

1
def __init__(route, origin, destination)

Initialize a Route object by passing the routing engine's route object.

Arguments:

  • route: An instance of a routing engine's route object

get_duration

1
def get_duration()

Get the duration of the route.

get_distance

1
def get_distance()

Get the distance of the route.

get_route

1
def get_route()

Get the raw route information.

get_route_geopandas

1
def get_route_geopandas()

Get the route information as a GeoDataFrame.

plot_route

1
def plot_route()

Plot the route on a map.

BaseRouter Objects

1
class BaseRouter(object)

The class BaseRouter serves as a base class for routers, which are used to compute the optimal route between two points. The class has an instance variable mode, which is a string that defines the mode of transportation (e.g. "driving").

The BaseRouter class has a single method _get_OD_matrix, which takes two arguments origins and destinations and returns an origin-destination matrix. The method creates an empty list items and loops through each origin and destination pair, appending the concatenated origin and destination to the list. The origin-destination matrix is then created from the list items and returned.

get_distances_batch

1
2
3
4
def get_distances_batch(origins,
                        destinations,
                        max_batch_size=25,
                        append_od=False)

This method returns a Pandas dataframe contains duration and disatnce for all the origins and destinations pairs. Use this function if you don't want to get duration and distance for all possible combinations between each origin and each destination.

The origins and destinations parameters are lists of origin-destination pairs. They should be the same length.

If the append_od parameter is set to True, the method also returns the input origin-destination pairs.

WebRouter Objects

1
class WebRouter(BaseRouter)

The WebRouter class is a class for handling a route obtained from a web-based routing service.