Latitude-Longitude String Parser

1.3.1 · active · verified Thu Apr 16

lat-lon-parser is a Python library designed for robustly parsing and converting latitude and longitude strings across various formats, including decimal degrees, degrees decimal minutes, and degrees minutes seconds. It provides functionality to parse coordinate strings into numerical values and to format numerical coordinates back into different string representations. The library's current version is 1.3.1, with the latest update on November 13, 2024, indicating active maintenance.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates parsing various latitude-longitude string formats into decimal degrees and converting numeric coordinates back into a human-readable string.

from lat_lon_parser import parse, to_str

# Parse a latitude-longitude string
coord_str_dms = "40° 26' 46\" N 79° 58' 56\" W"
decimal_degrees = parse(coord_str_dms)
print(f"Parsed '{coord_str_dms}' to: {decimal_degrees}°")

# Parse a decimal degrees string
coord_str_dec = "23.43 N -45.21 W"
decimal_degrees_2 = parse(coord_str_dec)
print(f"Parsed '{coord_str_dec}' to: {decimal_degrees_2}°")

# Convert decimal degrees to a formatted string
lat_val = 34.1234
lon_val = -118.5678
formatted_str = to_str(lat_val, lon_val)
print(f"Converted {lat_val}, {lon_val} to: {formatted_str}")

view raw JSON →