Skip to content

Isoline Routing API

IsolineRoutingApi

A python interface into the HERE Isoline Routing API

__init__(self, api_key=None, timeout=None) special

Returns a IsolineRoutingApi instance.

Parameters:

Name Type Description Default
api_key str

API key taken from HERE Developer Portal.

None
timeout int

Timeout limit for requests.

None
Source code in herepy/isoline_routing_api.py
def __init__(self, api_key: str = None, timeout: int = None):
    """Returns a IsolineRoutingApi instance.
    Args:
      api_key (str):
        API key taken from HERE Developer Portal.
      timeout (int):
        Timeout limit for requests.
    """

    super(IsolineRoutingApi, self).__init__(api_key, timeout)
    self._base_url = "https://isoline.router.hereapi.com/v8/isolines"

distance_based_isoline(self, transport_mode, origin, ranges, routing_mode)

A distance-based isoline, also called an Isodistance, can be requested using range[type]=distance and providing range[values] in meters.

Parameters:

Name Type Description Default
transport_mode IsolineRoutingTransportMode

Transport mode of routing.

required
origin List[float]

List including latitude and longitude in order.

required
ranges List[int]

List of range values for isoline (in meters).

required
routing_mode IsolineRoutingMode

Isoline routing mode.

required

Returns:

Type Description
Optional[herepy.models.IsolineRoutingResponse]

IsolineRoutingResponse

Source code in herepy/isoline_routing_api.py
def distance_based_isoline(
    self,
    transport_mode: IsolineRoutingTransportMode,
    origin: List[float],
    ranges: List[int],
    routing_mode: IsolineRoutingMode,
) -> Optional[IsolineRoutingResponse]:
    """A distance-based isoline, also called an Isodistance,
    can be requested using range[type]=distance and providing range[values] in meters.
    Args:
      transport_mode (IsolineRoutingTransportMode):
        Transport mode of routing.
      origin (List):
        List including latitude and longitude in order.
      ranges (List):
        List of range values for isoline (in meters).
      routing_mode (IsolineRoutingMode):
        Isoline routing mode.
    Returns:
      IsolineRoutingResponse
    Raises:
      HEREError"""

    string_ranges = [str(int) for int in ranges]
    data = {
        "transportMode": transport_mode.__str__(),
        "origin": str.format("{0},{1}", origin[0], origin[1]),
        "range[type]": IsolineRoutingRangeType.distance.__str__(),
        "range[values]": ",".join(string_ranges),
        "routingMode": routing_mode.__str__(),
        "apiKey": self._api_key,
    }
    return self.__get(self._base_url, data, "departure")

isoline_based_on_consumption(self, origin, ranges, transport_mode, free_flow_speed_table, traffic_speed_table, ascent, descent, auxiliary_consumption)

Electric vehicles have a limited reachable range based on their current battery charge and factors affecting the rate of energy consumed, such as road slope or auxiliary power usage. Therefore, it is useful to visualize the appropriate range to avoid running out of energy before reaching a charging point.

Parameters:

Name Type Description Default
transport_mode IsolineRoutingTransportMode

Transport mode of routing.

required
origin List[float]

List including latitude and longitude in order.

required
ranges List[int]

List of range values for isoline (in meters).

required
transport_mode IsolineRoutingTransportMode

Transport mode of routing.

required
free_flow_speed_table List[float]

Free flow speed table.

required
traffic_speed_table List[float]

Traffic speed table.

required
ascent int

Int value of ascent.

required
descent float

Value of descent.

required
auxiliary_consumption float

Auxiliary consumption.

required

Returns:

Type Description

IsolineRoutingResponse

Source code in herepy/isoline_routing_api.py
def isoline_based_on_consumption(
    self,
    origin: List[float],
    ranges: List[int],
    transport_mode: IsolineRoutingTransportMode,
    free_flow_speed_table: List[float],
    traffic_speed_table: List[float],
    ascent: int,
    descent: float,
    auxiliary_consumption: float,
):
    """Electric vehicles have a limited reachable range based on their current battery
    charge and factors affecting the rate of energy consumed, such as road slope or auxiliary
    power usage. Therefore, it is useful to visualize the appropriate range to avoid running
    out of energy before reaching a charging point.
    Args:
      transport_mode (IsolineRoutingTransportMode):
        Transport mode of routing.
      origin (List):
        List including latitude and longitude in order.
      ranges (List):
        List of range values for isoline (in meters).
      transport_mode (IsolineRoutingTransportMode):
        Transport mode of routing.
      free_flow_speed_table (List[float]):
        Free flow speed table.
      traffic_speed_table (List[float]):
        Traffic speed table.
      ascent (int):
        Int value of ascent.
      descent (float):
        Value of descent.
      auxiliary_consumption (float):
        Auxiliary consumption.
    Returns:
      IsolineRoutingResponse
    Raises:
      HEREError"""

    string_ranges = [str(int) for int in ranges]

    free_speed_table = [0]
    free_speed_table.extend(free_flow_speed_table)
    free_speed_table_str = ",".join([str(n) for n in free_speed_table])

    speed_table = [0]
    speed_table.extend(traffic_speed_table)
    speed_table_str = ",".join([str(n) for n in speed_table])

    data = {
        "origin": str.format("{0},{1}", origin[0], origin[1]),
        "range[type]": IsolineRoutingRangeType.consumption.__str__(),
        "range[values]": ",".join(string_ranges),
        "transportMode": transport_mode.__str__(),
        "ev[freeFlowSpeedTable]": free_speed_table_str,
        "ev[trafficSpeedTable]": speed_table_str,
        "ev[ascent]": ascent,
        "ev[descent]": descent,
        "ev[auxiliaryConsumption]": auxiliary_consumption,
        "apiKey": self._api_key,
    }
    return self.__get(self._base_url, data, "departure")

isoline_routing_at_specific_time(self, transport_mode, ranges, origin=None, departure_time=None, destination=None, arrival_time=None)

To calculate an isoline around an origin with a specific time, use departureTime. For a reverse isoline, that is, when using destination, you can use arrivalTime. If departureTime or arrivalTime are specified as "any", the isoline calculation will not take traffic flow and other time-dependent effects into account. This can be useful when it is not certain for what time of the day the isoline needs to be computed.

Parameters:

Name Type Description Default
transport_mode IsolineRoutingTransportMode

Transport mode of routing.

required
ranges List[int]

List of range values for isoline (in meters).

required
origin Optional[List[float]]

List including latitude and longitude in order.

None
departure_time Optional[str]

Departure time of the routing in format yyyy-MM-ddThh:mm:ss.

None
destination Optional[List[float]]

List including latitude and longitude in order.

None
arrival_time Optional[str]

Arrival time of the planned routing in format yyyy-MM-ddThh:mm:ss.

None

Returns:

Type Description

IsolineRoutingResponse

Source code in herepy/isoline_routing_api.py
def isoline_routing_at_specific_time(
    self,
    transport_mode: IsolineRoutingTransportMode,
    ranges: List[int],
    origin: Optional[List[float]] = None,
    departure_time: Optional[str] = None,
    destination: Optional[List[float]] = None,
    arrival_time: Optional[str] = None,
):
    """To calculate an isoline around an origin with a specific time, use departureTime.
    For a reverse isoline, that is, when using destination, you can use arrivalTime.
    If departureTime or arrivalTime are specified as "any", the isoline calculation will
    not take traffic flow and other time-dependent effects into account. This can be useful
    when it is not certain for what time of the day the isoline needs to be computed.
    Args:
      transport_mode (IsolineRoutingTransportMode):
        Transport mode of routing.
      ranges (List):
        List of range values for isoline (in meters).
      origin (List):
        List including latitude and longitude in order.
      departure_time (str):
        Departure time of the routing in format yyyy-MM-ddThh:mm:ss.
      destination (List):
        List including latitude and longitude in order.
      arrival_time (str):
        Arrival time of the planned routing in format yyyy-MM-ddThh:mm:ss.
    Returns:
      IsolineRoutingResponse
    Raises:
      HEREError"""

    string_ranges = [str(int) for int in ranges]
    if origin and departure_time:
        data = {
            "transportMode": transport_mode.__str__(),
            "origin": str.format("{0},{1}", origin[0], origin[1]),
            "departureTime": departure_time,
            "range[type]": IsolineRoutingRangeType.time.__str__(),
            "range[values]": ",".join(string_ranges),
            "apiKey": self._api_key,
        }
        return self.__get(self._base_url, data, "departure")
    elif destination and arrival_time:
        data = {
            "transportMode": transport_mode.__str__(),
            "destination": str.format("{0},{1}", destination[0], destination[1]),
            "arrivalTime": arrival_time,
            "range[type]": IsolineRoutingRangeType.time.__str__(),
            "range[values]": ",".join(string_ranges),
            "apiKey": self._api_key,
        }
        return self.__get(self._base_url, data, "arrival")
    else:
        raise HEREError(
            "Please provide either origin & departure_time or destination & arrival_time."
        )

multi_range_routing(self, transport_mode, ranges, origin=None, destination=None)

Isoline routing can be requested with multiple ranges which allows for the calculation of many isolines with the same start or destination.

Parameters:

Name Type Description Default
transport_mode IsolineRoutingTransportMode

Transport mode of routing.

required
ranges List[int]

Range values for isoline routing.

required
origin Optional[List[float]]

List including latitude and longitude in order.

None
destination Optional[List[float]]

List including latitude and longitude in order.

None

Returns:

Type Description

IsolineRoutingResponse

Source code in herepy/isoline_routing_api.py
def multi_range_routing(
    self,
    transport_mode: IsolineRoutingTransportMode,
    ranges: List[int],
    origin: Optional[List[float]] = None,
    destination: Optional[List[float]] = None,
):
    """Isoline routing can be requested with multiple ranges which allows for the calculation
    of many isolines with the same start or destination.
    Args:
      transport_mode (IsolineRoutingTransportMode):
        Transport mode of routing.
      ranges (List):
        Range values for isoline routing.
      origin (List):
        List including latitude and longitude in order.
      destination (List):
        List including latitude and longitude in order.
    Returns:
      IsolineRoutingResponse
    Raises:
      HEREError"""

    string_ranges = [str(int) for int in ranges]
    if origin:
        data = {
            "transportMode": transport_mode.__str__(),
            "origin": str.format("{0},{1}", origin[0], origin[1]),
            "range[type]": IsolineRoutingRangeType.distance.__str__(),
            "range[values]": ",".join(string_ranges),
            "apiKey": self._api_key,
        }
        return self.__get(self._base_url, data, "departure")
    elif destination:
        data = {
            "transportMode": transport_mode.__str__(),
            "destination": str.format("{0},{1}", destination[0], destination[1]),
            "range[type]": IsolineRoutingRangeType.distance.__str__(),
            "range[values]": ",".join(string_ranges),
            "apiKey": self._api_key,
        }
        return self.__get(self._base_url, data, "arrival")
    else:
        raise HEREError(
            "Please provide values for origin or destination parameter."
        )

reverse_direction_isoline(self, transport_mode, ranges, origin=None, destination=None)

Calculates an isoline in the reverse direction. To trigger calculation in reverse direction, use the destination parameter instead of origin.

Parameters:

Name Type Description Default
transport_mode IsolineRoutingTransportMode

Transport mode of routing.

required
ranges List[int]

Range values for isoline routing.

required
origin Optional[List[float]]

List including latitude and longitude in order.

None
destination Optional[List[float]]

List including latitude and longitude in order.

None

Returns:

Type Description

IsolineRoutingResponse

Source code in herepy/isoline_routing_api.py
def reverse_direction_isoline(
    self,
    transport_mode: IsolineRoutingTransportMode,
    ranges: List[int],
    origin: Optional[List[float]] = None,
    destination: Optional[List[float]] = None,
):
    """Calculates an isoline in the reverse direction. To trigger calculation in reverse direction,
    use the destination parameter instead of origin.
    Args:
      transport_mode (IsolineRoutingTransportMode):
        Transport mode of routing.
      ranges (List):
        Range values for isoline routing.
      origin (List):
        List including latitude and longitude in order.
      destination (List):
        List including latitude and longitude in order.
    Returns:
      IsolineRoutingResponse
    Raises:
      HEREError"""

    string_ranges = [str(int) for int in ranges]
    if origin:
        data = {
            "transportMode": transport_mode.__str__(),
            "origin": str.format("{0},{1}", origin[0], origin[1]),
            "range[type]": IsolineRoutingRangeType.time.__str__(),
            "range[values]": ",".join(string_ranges),
            "apiKey": self._api_key,
        }
        return self.__get(self._base_url, data, "departure")
    elif destination:
        data = {
            "transportMode": transport_mode.__str__(),
            "destination": str.format("{0},{1}", destination[0], destination[1]),
            "range[type]": IsolineRoutingRangeType.time.__str__(),
            "range[values]": range,
            "apiKey": self._api_key,
        }
        return self.__get(self._base_url, data, "arrival")
    else:
        raise HEREError(
            "Please provide values for origin or destination parameter."
        )

time_isoline(self, transport_mode, origin, ranges)

A time-based isoline, also called an Isochrone, can be requested by using range[type]=time and providing range[values] in seconds.

Parameters:

Name Type Description Default
transport_mode IsolineRoutingTransportMode

Transport mode of routing.

required
origin List[float]

List including latitude and longitude in order.

required
ranges List[int]

List of range values for isoline (in meters).

required

Returns:

Type Description
Optional[herepy.models.IsolineRoutingResponse]

IsolineRoutingResponse

Source code in herepy/isoline_routing_api.py
def time_isoline(
    self,
    transport_mode: IsolineRoutingTransportMode,
    origin: List[float],
    ranges: List[int],
) -> Optional[IsolineRoutingResponse]:
    """A time-based isoline, also called an Isochrone,
    can be requested by using range[type]=time and providing range[values] in seconds.
    Args:
      transport_mode (IsolineRoutingTransportMode):
        Transport mode of routing.
      origin (List):
        List including latitude and longitude in order.
      ranges (List):
        List of range values for isoline (in meters).
    Returns:
      IsolineRoutingResponse
    Raises:
      HEREError"""

    string_ranges = [str(int) for int in ranges]
    data = {
        "transportMode": transport_mode.__str__(),
        "origin": str.format("{0},{1}", origin[0], origin[1]),
        "range[type]": IsolineRoutingRangeType.time.__str__(),
        "range[values]": ",".join(string_ranges),
        "apiKey": self._api_key,
    }
    return self.__get(self._base_url, data, "departure")