geopy#

Geocoding and coordinate utilities for Swiss and global use cases.

See geopy for usage examples.

API Reference#

exception pyedautils.geopy.GeocodingError[source]#

Bases: Exception

pyedautils.geopy.convert_wsg84_to_lv95(lat: float, long: float) → List[float][source]#

Converts WGS84 latitude and longitude coordinates to Swiss coordinate system LV95.

Parameters:
  • lat (float) – Latitude in decimal degrees.

  • long (float) – Longitude in decimal degrees.

Returns:

A list containing x and y coordinates in LV95 system, e.g., [xcoord, ycoord].

Return type:

List[float]

pyedautils.geopy.get_altitude_lv95(coord_list_lv95: List[float]) → float[source]#

Returns altitude in meters above sea level for the given LV95 coordinates. The geo.admin.ch api gets used.

Parameters:

coord_list_lv95 (List[float]) – LV95 coordinates as [xcoord, ycoord].

Returns:

Altitude in meters above sea level.

Return type:

float

pyedautils.geopy.get_altitude_lat_long(lat: float, long: float) → float[source]#

Returns altitude in meters above sea level for the given WGS84 coordinates. The opentopodata.org api gets used.

Parameters:
  • lat (float) – Latitude in decimal degrees.

  • long (float) – Longitude in decimal degrees.

Returns:

Altitude in meters above sea level.

Return type:

float

pyedautils.geopy.get_lat_long_address(address: str) → List[float] | None[source]#

Returns latitude and longitude coordinates for the given address.

Parameters:

address (str) – The address to geocode.

Returns:

A list containing latitude and longitude coordinates,

e.g., [latitude, longitude], or None if the address could not be geocoded.

Return type:

Union[List[float], None]

pyedautils.geopy.get_coordinates_ch_plz(plz: int) → Tuple[float, float][source]#

Returns latitude and longitude for a Swiss postal code.

Parameters:

plz (int) – Postal Code (Postleitzahl)

Returns:

float, lon: float)

Return type:

tuple (lat

pyedautils.geopy.get_coordindates_ch_plz(plz: int) → Tuple[float, float][source]#

Deprecated alias of get_coordinates_ch_plz() (misspelled name).

Emits a DeprecationWarning; use get_coordinates_ch_plz() instead.

pyedautils.geopy.get_distance_between_two_points(coord1, coord2)[source]#

Calculates the distance between two points on the Earth’s surface given their latitude and longitude coordinates.

Parameters:
  • coord1 (tuple) – Latitude and longitude of the first point in degrees, as a tuple (lat1, lon1).

  • coord2 (tuple) – Latitude and longitude of the second point in degrees, as a tuple (lat2, lon2).

Returns:

Distance between the two points in kilometers.

Return type:

float