geo module

This module contains a collection of functions related to geographical data.

geo.haversine(a, b)

Function that calculates the haversine distances between two points in kilometers.

Parameters:
  • a (tuple) – The coordinate of the first point as (latitude, longitude).
  • b (tuple) – The coordinate of the second point as (latitude, longitude).
Returns:

Haversine distance.

Return type:

float

geo.rivers_by_station_number(stations, N)

Function that returns a list of tuples containing the river name and the number of stations it has.

Parameters:
  • stations (list) – List of stations (MonitoringStation)
  • N (int) – The number of desired rivers with the largest number of stations
Returns:

tuple of (river, number of stations on river) sorted in descending order

Return type:

list

geo.rivers_with_station(stations)

Function that, given a list of station objects, returns a container with the names of the rivers with a monitoring station.

Parameters:stations (list) – List of stations (MonitoringStation).
Returns:Set of names of rivers with a monitoring station.
Return type:set
geo.stations_by_distance(stations, p)

Function that returns the sorted distances between the input stations and a specified point p.

Parameters:
  • stations (list) – List of stations (MonitoringStation).
  • p (tuple) – Coordinate of the origin.
Returns:

List of (station, distance) sorted by distance.

Return type:

list

geo.stations_by_river(stations)

Function that returns a dictionary that maps river names (the ‘key’) to a list of station objects on a given river.

Parameters:stations (list) – List of stations (MonitoringStation).
Returns:Keys - river names.
Return type:dict
geo.stations_within_radius(stations, centre, r)

Function that returns a list of all stations (MonitoringStation) within radius r of a geographic coordinate.

Parameters:
  • stations (list) – List of stations (MonitoringStation).
  • centre (tuple) – Coordinate of centre in (latitude, longitude).
  • r (float) – Radius in kilometers.
Returns:

List of stations (MonitoringStation) within the distance.

Return type:

list