lat-lon-parser


Namelat-lon-parser JSON
Version 1.3.0 PyPI version JSON
download
home_pagehttps://github.com/NOAA-ORR-ERD/lat_lon_parser
SummarySimple parser for latitude-longitude strings
upload_time2022-04-27 21:13:27
maintainer
docs_urlNone
authorChristopher Barker
requires_python
license
keywords lat_lon_parser
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. image:: https://github.com/NOAA-ORR-ERD/lat_lon_parser/workflows/CI/badge.svg
  :target: https://github.com/NOAA-ORR-ERD/lat_lon_parser/actions?query=workflow%3ACI

.. image:: https://img.shields.io/pypi/v/lat-lon-parser.svg
  :target: https://pypi.org/project/lat-lon-parser/

.. image:: https://img.shields.io/pypi/pyversions/lat-lon-parser.svg
  :target: https://pypi.org/project/lat-lon-parser/

.. image:: https://img.shields.io/github/license/NOAA-ORR-ERD/lat_lon_parser
  :target: https://github.com/NOAA-ORR-ERD/lat_lon_parser/




##############
lat_lon_parser
##############

Code for parsing lat-long coordinates in "various" formats, and for converting between lat-long formats (e.g. decimal degrees to degrees-minutes-seconds)

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.

Parsing Latitude and Longitude strings
=======================================

Usage:
------

from lat_lon_parser import parse

.. code-block::

    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

How it works:
-------------

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.


Conversion to Latitude Longitude Formats
========================================

Also included is code to convert to other formats used for latitude and longitude:

- degrees
- degrees minutes
- degrees minutes seconds

Converting to numbers:
----------------------

Functions for returning tuples of numbers::

  >>> to_dec_deg(23, 12, 3)
  23.200833333333332
  >>> to_deg_min(34.1234)
  (34.0, 7.404)
  >>> to_deg_min_sec(34.1234)
  (34.0, 7, 24.24)


Converting to strings:
----------------------

Functions for converting to various string formats::

  >>> to_str_dec_deg(23, 12, 3)
  '23.200833°'
  >>> to_str_deg_min(2.345)
  "2° 20.700'"
  >>> to_str_deg_min_sec(-23.1234)
  '-23° 7\' 24.24"'

  >>> to_str(23.45)
  '23.450000°'
  >>> to_str(23, 45)
  "23° 45.000'"
  >>> to_str(23, 45, 6.7)
  '23° 45\' 6.70"'






            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/NOAA-ORR-ERD/lat_lon_parser",
    "name": "lat-lon-parser",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "lat_lon_parser",
    "author": "Christopher Barker",
    "author_email": "Chris.Barker@noaa.gov",
    "download_url": "https://files.pythonhosted.org/packages/7d/2b/81e2823a820449daaa2ad4d9b8299981e8cb6620669ef9c34f7438c66891/lat_lon_parser-1.3.0.tar.gz",
    "platform": null,
    "description": ".. image:: https://github.com/NOAA-ORR-ERD/lat_lon_parser/workflows/CI/badge.svg\n  :target: https://github.com/NOAA-ORR-ERD/lat_lon_parser/actions?query=workflow%3ACI\n\n.. image:: https://img.shields.io/pypi/v/lat-lon-parser.svg\n  :target: https://pypi.org/project/lat-lon-parser/\n\n.. image:: https://img.shields.io/pypi/pyversions/lat-lon-parser.svg\n  :target: https://pypi.org/project/lat-lon-parser/\n\n.. image:: https://img.shields.io/github/license/NOAA-ORR-ERD/lat_lon_parser\n  :target: https://github.com/NOAA-ORR-ERD/lat_lon_parser/\n\n\n\n\n##############\nlat_lon_parser\n##############\n\nCode for parsing lat-long coordinates in \"various\" formats, and for converting between lat-long formats (e.g. decimal degrees to degrees-minutes-seconds)\n\nNote: perhaps it would be better to integrate this with a more full featured lib like:\n\nhttps://pypi.python.org/pypi/LatLon23\n\nBut 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.\n\nParsing Latitude and Longitude strings\n=======================================\n\nUsage:\n------\n\nfrom lat_lon_parser import parse\n\n.. code-block::\n\n    In [12]: from lat_lon_parser import parse\n\n    In [13]: parse(\"45\u00b0 12.6' W\")\n    Out[13]: -45.21\n\n\nFormats supported:\n------------------\n\nDecimal degrees (easy)::\n\n   23.43\n   -45.21\n\nDecimal Degrees with quadrant::\n\n   23.43 N\n   45.21 W\n\nOr with spelled out::\n\n   23.43 North\n   45.21 West\n\n(note that all of the cardinal directions are not case-sensitive)\n\nDegrees, decimal minutes: (now it starts getting tricky!)::\n\n  23\u00b0 25.800'\n  -45\u00b0 12.600'\n\nor::\n\n  23 25.800'\n  -45 12.600'\n\nor::\n\n  23\u00b0 25.8' N\n  45\u00b0 12.6' West\n\nDegrees, Minutes, Seconds: (really fun!!!)::\n\n   23\u00b0 25' 48.0\"\n  -45\u00b0 12' 36.0\"\n\nor::\n\n   23d 25' 48.0\"\n  -45d 12' 36.0\"\n\nor::\n\n  23\u00b0 25' 48.0\" North\n  45\u00b0 12' 36.0\" S\n\nor -- lots of other combinations!\n\nFor a more complete list, see the tests\n\nHow it works:\n-------------\n\nThis uses a pretty \"stupid\" algorithm -- it assumes that all formats will be something like:\n\n[-][space] degrees [separator] minutes [separator] seconds [separator] [N[orth]|S[outh|E[ast]|W[est]]\n\nBut that actually is pretty darn robust!\n\nIf 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.\n\n\nConversion to Latitude Longitude Formats\n========================================\n\nAlso included is code to convert to other formats used for latitude and longitude:\n\n- degrees\n- degrees minutes\n- degrees minutes seconds\n\nConverting to numbers:\n----------------------\n\nFunctions for returning tuples of numbers::\n\n  >>> to_dec_deg(23, 12, 3)\n  23.200833333333332\n  >>> to_deg_min(34.1234)\n  (34.0, 7.404)\n  >>> to_deg_min_sec(34.1234)\n  (34.0, 7, 24.24)\n\n\nConverting to strings:\n----------------------\n\nFunctions for converting to various string formats::\n\n  >>> to_str_dec_deg(23, 12, 3)\n  '23.200833\u00b0'\n  >>> to_str_deg_min(2.345)\n  \"2\u00b0 20.700'\"\n  >>> to_str_deg_min_sec(-23.1234)\n  '-23\u00b0 7\\' 24.24\"'\n\n  >>> to_str(23.45)\n  '23.450000\u00b0'\n  >>> to_str(23, 45)\n  \"23\u00b0 45.000'\"\n  >>> to_str(23, 45, 6.7)\n  '23\u00b0 45\\' 6.70\"'\n\n\n\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Simple parser for latitude-longitude strings",
    "version": "1.3.0",
    "project_urls": {
        "Homepage": "https://github.com/NOAA-ORR-ERD/lat_lon_parser"
    },
    "split_keywords": [
        "lat_lon_parser"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2877eeca4dbd18c7db8ee8ce0f14c4a10cd3a06a10b4bf6a8a1c88b62bd4f902",
                "md5": "d449ae8555d7aa3f9df74cc3728c8e12",
                "sha256": "681dca0f4db231f7215fe1957f4bb8d27e603a5a5f43059d2f8bf8554c2ba4c8"
            },
            "downloads": -1,
            "filename": "lat_lon_parser-1.3.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d449ae8555d7aa3f9df74cc3728c8e12",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 10909,
            "upload_time": "2022-04-27T21:15:46",
            "upload_time_iso_8601": "2022-04-27T21:15:46.905902Z",
            "url": "https://files.pythonhosted.org/packages/28/77/eeca4dbd18c7db8ee8ce0f14c4a10cd3a06a10b4bf6a8a1c88b62bd4f902/lat_lon_parser-1.3.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7d2b81e2823a820449daaa2ad4d9b8299981e8cb6620669ef9c34f7438c66891",
                "md5": "9bb223dd8a89b18b45459d08253597e6",
                "sha256": "e3a65dacd5b25a18c56e3ae31b11cd724480be7fe8db2df1c46ed0dd322a1fca"
            },
            "downloads": -1,
            "filename": "lat_lon_parser-1.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "9bb223dd8a89b18b45459d08253597e6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 12425,
            "upload_time": "2022-04-27T21:13:27",
            "upload_time_iso_8601": "2022-04-27T21:13:27.635681Z",
            "url": "https://files.pythonhosted.org/packages/7d/2b/81e2823a820449daaa2ad4d9b8299981e8cb6620669ef9c34f7438c66891/lat_lon_parser-1.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-04-27 21:13:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "NOAA-ORR-ERD",
    "github_project": "lat_lon_parser",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "lat-lon-parser"
}
        
Elapsed time: 0.30190s