Skip to main content

Code for parsing lat-long coordinates in “various” formats

Note: perhaps it would be better to integrate this with a more full featured lib like:

https://pypi.python.org/pypi/LatLon23

But that one does not seem to support parsing unknown formats at this point – and it’s GPL, and perhaps a little more complex and structured than it needs to be.

Usage:

from lat_lon_parser import parse

In [12]: from lat_lon_parser import parse

In [13]: parse("45° 12.6' W")
Out[13]: -45.21

Formats supported:

Decimal degrees (easy):

23.43
-45.21

Decimal Degrees with quadrant:

23.43 N
45.21 W

Or with spelled out:

23.43 North
45.21 West

(note that all of the cardinal directions are not case-sensitive)

Degrees, decimal minutes: (now it starts getting tricky!):

23° 25.800'
-45° 12.600'

or:

23 25.800'
-45 12.600'

or:

23° 25.8' N
45° 12.6' West

Degrees, Minutes, Seconds: (really fun!!!):

 23° 25' 48.0"
-45° 12' 36.0"

or:

 23d 25' 48.0"
-45d 12' 36.0"

or:

23° 25' 48.0" North
45° 12' 36.0" S

or – lots of other combinations!

For a more complete list, see the tests

Adding to the options:

This uses a pretty “stupid” algorithm – it assumes that all formats will be something like:

[-][space] degrees [separator] minutes [separator] seconds [separator] [N[orth]|S[outh|E[ast]|W[est]]

But that actually is pretty darn robust!

If you have other formats you want to be able to parse, please contribute tests! – And ideally a patch if the current code doesn’t work.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lat_lon_parser-1.1.3.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lat_lon_parser-1.1.3-py2.py3-none-any.whl (11.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file lat_lon_parser-1.1.3.tar.gz.

File metadata

  • Download URL: lat_lon_parser-1.1.3.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.2.0.post20200511 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for lat_lon_parser-1.1.3.tar.gz
Algorithm Hash digest
SHA256 d8b7058475906f5df6116164dfa24eeffed4819d383d0d43da58fabffe218750
MD5 f7d48f18d89cafe41aaaa1405b7bab6b
BLAKE2b-256 191ca1db9c4add30c62888ef01c33066ba4c65bb9fc2ef5c28e3438fbfb2720a

See more details on using hashes here.

File details

Details for the file lat_lon_parser-1.1.3-py2.py3-none-any.whl.

File metadata

  • Download URL: lat_lon_parser-1.1.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.2.0.post20200511 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for lat_lon_parser-1.1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 91a4916ec0cf1bf31ca34d5176eb0e9065ea855845eb7348e3d9d97fb68d3db6
MD5 f7dca3095e08da732ac21668fdef6c5d
BLAKE2b-256 89d15bbc155c9b264877a646276c66ea7352c504c54b5533639ad1b50295d36c

See more details on using hashes here.

Release history Release notifications | RSS feed

1.3.1

2 files

1.3.0

2 files

1.2.0

2 files

This release

1.1.3 This release

2 files

1.1.2

1 file

1.1.1

1 file

1.1.0

1 file

1.0.0

1 file

0.1.0

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page