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.
pip install lat-lon-parserVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing various latitude-longitude string formats into decimal degrees and converting numeric coordinates back into a human-readable string.
For unsupported formats, review the library's test cases on GitHub for similar patterns or consider contributing a patch/test case.
Ensure input strings contain only the coordinate, use correct symbols, verify values are within geographic ranges, and confirm the order of latitude and longitude (typically latitude first).
Simplify the input string to contain only the coordinate values and hemisphere indicators. Remove any descriptive text, labels, or unrecognised symbols. For example, change 'Lat: 45.123, Lon: -123.456' to '45.123, -123.456'.
Double-check the order of the parsed coordinates. Latitudes range from -90 to +90, while longitudes range from -180 to +180. If a value greater than 90 appears in the latitude position, it's likely a transposition. Swap the order of the input values or adjust how they are passed to ensure latitude corresponds to latitude and longitude to longitude.