utm


Nameutm JSON
Version 0.8.0 PyPI version JSON
download
home_pagehttps://github.com/Turbo87/utm
SummaryBidirectional UTM-WGS84 converter for python
upload_time2025-01-24 11:59:52
maintainerNone
docs_urlNone
authorTobias Bieniek
requires_pythonNone
licenseNone
keywords utm wgs84 coordinate converter
VCS
bugtrack_url
requirements pytest pytest-cov pytest-cov
Travis-CI No Travis.
coveralls test coverage No coveralls.
            utm
===

Bidirectional UTM-WGS84 converter for python

Usage
-----

.. code-block:: python

  >>> import utm

Latitude/Longitude to UTM
^^^^^^^^^^^^^^^^^^^^^^^^^

Convert a ``(latitude, longitude)`` tuple into an UTM coordinate:

.. code-block:: python

  >>> utm.from_latlon(51.2, 7.5)
  (395201.3103811303, 5673135.241182375, 32, 'U')

The syntax is ``utm.from_latlon(LATITUDE, LONGITUDE)``.

The return has the form ``(EASTING, NORTHING, ZONE_NUMBER, ZONE_LETTER)``.

You can also use NumPy arrays for ``LATITUDE`` and ``LONGITUDE``. In the
result ``EASTING`` and ``NORTHING`` will have the same shape.  ``ZONE_NUMBER``
and ``ZONE_LETTER`` are scalars and will be calculated for the first point of
the input. All other points will be set into the same UTM zone.  Therefore
it's a good idea to make sure all points are near each other.

.. code-block:: python

  >>> utm.from_latlon(np.array([51.2, 49.0]), np.array([7.5, 8.4]))
  (array([395201.31038113, 456114.59586214]),
   array([5673135.24118237, 5427629.20426126]),
   32,
   'U')


UTM to Latitude/Longitude
^^^^^^^^^^^^^^^^^^^^^^^^^

Convert an UTM coordinate into a ``(latitude, longitude)`` tuple:

.. code-block:: python

  >>> utm.to_latlon(340000, 5710000, 32, 'U')
  (51.51852098408468, 6.693872395145327)

The syntax is ``utm.to_latlon(EASTING, NORTHING, ZONE_NUMBER, ZONE_LETTER)``.

The return has the form ``(LATITUDE, LONGITUDE)``.

You can also use NumPy arrays for ``EASTING`` and ``NORTHING``. In the result
``LATITUDE`` and ``LONGITUDE`` will have the same shape.  ``ZONE_NUMBER`` and
``ZONE_LETTER`` are scalars.

.. code-block:: python

    >>> utm.to_latlon(np.array([395200, 456100]), np.array([5673100, 5427600]), 32, 'U')
    (array([51.19968297, 48.99973627]), array([7.49999141, 8.3998036 ]))


Since the zone letter is not strictly needed for the conversion you may also
the ``northern`` parameter instead, which is a named parameter and can be set
to either ``True`` or ``False``. Have a look at the unit tests to see how it
can be used.

The UTM coordinate system is explained on
`this <https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system>`_
Wikipedia page.

Speed
-----

The library has been compared to the more generic pyproj library by running
the unit test suite through pyproj instead of utm. These are the results:

* with pyproj (without projection cache): 4.0 - 4.5 sec
* with pyproj (with projection cache): 0.9 - 1.0 sec
* with utm: 0.4 - 0.5 sec

NumPy arrays bring another speed improvement (on a different computer than the
previous test). Using ``utm.from_latlon(x, y)`` to convert one million points:

* one million calls (``x`` and ``y`` are floats): 1,000,000 × 90µs = 90s
* one call (``x`` and ``y`` are numpy arrays of one million points): 0.26s

Development
-----------

Create a new ``virtualenv`` and install the library via ``pip install -e .``.
After that install the ``pytest`` package via ``pip install pytest`` and run
the unit test suite by calling ``pytest``.

Changelog
---------

see `CHANGELOG.rst <CHANGELOG.rst>`_ file

Authors
-------

* Bart van Andel <bavanandel@gmail.com>
* Tobias Bieniek <Tobias.Bieniek@gmx.de>
* Torstein I. Bø

License
-------

Copyright (C) 2012 Tobias Bieniek <Tobias.Bieniek@gmx.de>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Turbo87/utm",
    "name": "utm",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "utm, wgs84, coordinate, converter",
    "author": "Tobias Bieniek",
    "author_email": "Tobias.Bieniek@gmx.de",
    "download_url": "https://files.pythonhosted.org/packages/c1/44/a5a1e611db2919f6521241b6e5538bb8a5b8a995a84143d5c0936397f07a/utm-0.8.0.tar.gz",
    "platform": null,
    "description": "utm\n===\n\nBidirectional UTM-WGS84 converter for python\n\nUsage\n-----\n\n.. code-block:: python\n\n  >>> import utm\n\nLatitude/Longitude to UTM\n^^^^^^^^^^^^^^^^^^^^^^^^^\n\nConvert a ``(latitude, longitude)`` tuple into an UTM coordinate:\n\n.. code-block:: python\n\n  >>> utm.from_latlon(51.2, 7.5)\n  (395201.3103811303, 5673135.241182375, 32, 'U')\n\nThe syntax is ``utm.from_latlon(LATITUDE, LONGITUDE)``.\n\nThe return has the form ``(EASTING, NORTHING, ZONE_NUMBER, ZONE_LETTER)``.\n\nYou can also use NumPy arrays for ``LATITUDE`` and ``LONGITUDE``. In the\nresult ``EASTING`` and ``NORTHING`` will have the same shape.  ``ZONE_NUMBER``\nand ``ZONE_LETTER`` are scalars and will be calculated for the first point of\nthe input. All other points will be set into the same UTM zone.  Therefore\nit's a good idea to make sure all points are near each other.\n\n.. code-block:: python\n\n  >>> utm.from_latlon(np.array([51.2, 49.0]), np.array([7.5, 8.4]))\n  (array([395201.31038113, 456114.59586214]),\n   array([5673135.24118237, 5427629.20426126]),\n   32,\n   'U')\n\n\nUTM to Latitude/Longitude\n^^^^^^^^^^^^^^^^^^^^^^^^^\n\nConvert an UTM coordinate into a ``(latitude, longitude)`` tuple:\n\n.. code-block:: python\n\n  >>> utm.to_latlon(340000, 5710000, 32, 'U')\n  (51.51852098408468, 6.693872395145327)\n\nThe syntax is ``utm.to_latlon(EASTING, NORTHING, ZONE_NUMBER, ZONE_LETTER)``.\n\nThe return has the form ``(LATITUDE, LONGITUDE)``.\n\nYou can also use NumPy arrays for ``EASTING`` and ``NORTHING``. In the result\n``LATITUDE`` and ``LONGITUDE`` will have the same shape.  ``ZONE_NUMBER`` and\n``ZONE_LETTER`` are scalars.\n\n.. code-block:: python\n\n    >>> utm.to_latlon(np.array([395200, 456100]), np.array([5673100, 5427600]), 32, 'U')\n    (array([51.19968297, 48.99973627]), array([7.49999141, 8.3998036 ]))\n\n\nSince the zone letter is not strictly needed for the conversion you may also\nthe ``northern`` parameter instead, which is a named parameter and can be set\nto either ``True`` or ``False``. Have a look at the unit tests to see how it\ncan be used.\n\nThe UTM coordinate system is explained on\n`this <https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system>`_\nWikipedia page.\n\nSpeed\n-----\n\nThe library has been compared to the more generic pyproj library by running\nthe unit test suite through pyproj instead of utm. These are the results:\n\n* with pyproj (without projection cache): 4.0 - 4.5 sec\n* with pyproj (with projection cache): 0.9 - 1.0 sec\n* with utm: 0.4 - 0.5 sec\n\nNumPy arrays bring another speed improvement (on a different computer than the\nprevious test). Using ``utm.from_latlon(x, y)`` to convert one million points:\n\n* one million calls (``x`` and ``y`` are floats): 1,000,000 \u00d7 90\u00b5s = 90s\n* one call (``x`` and ``y`` are numpy arrays of one million points): 0.26s\n\nDevelopment\n-----------\n\nCreate a new ``virtualenv`` and install the library via ``pip install -e .``.\nAfter that install the ``pytest`` package via ``pip install pytest`` and run\nthe unit test suite by calling ``pytest``.\n\nChangelog\n---------\n\nsee `CHANGELOG.rst <CHANGELOG.rst>`_ file\n\nAuthors\n-------\n\n* Bart van Andel <bavanandel@gmail.com>\n* Tobias Bieniek <Tobias.Bieniek@gmx.de>\n* Torstein I. B\u00f8\n\nLicense\n-------\n\nCopyright (C) 2012 Tobias Bieniek <Tobias.Bieniek@gmx.de>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Bidirectional UTM-WGS84 converter for python",
    "version": "0.8.0",
    "project_urls": {
        "Homepage": "https://github.com/Turbo87/utm"
    },
    "split_keywords": [
        "utm",
        " wgs84",
        " coordinate",
        " converter"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "c144a5a1e611db2919f6521241b6e5538bb8a5b8a995a84143d5c0936397f07a",
                "md5": "f2835d4415a3d4a779cebf7fabb2b1c3",
                "sha256": "37143e7bad8390ad974fdb66de3156128f798ac54f861c2cd1c931ab411568aa"
            },
            "downloads": -1,
            "filename": "utm-0.8.0.tar.gz",
            "has_sig": false,
            "md5_digest": "f2835d4415a3d4a779cebf7fabb2b1c3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 13042,
            "upload_time": "2025-01-24T11:59:52",
            "upload_time_iso_8601": "2025-01-24T11:59:52.649859Z",
            "url": "https://files.pythonhosted.org/packages/c1/44/a5a1e611db2919f6521241b6e5538bb8a5b8a995a84143d5c0936397f07a/utm-0.8.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-24 11:59:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Turbo87",
    "github_project": "utm",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "pytest",
            "specs": [
                [
                    "==",
                    "8.3.4"
                ]
            ]
        },
        {
            "name": "pytest-cov",
            "specs": [
                [
                    "==",
                    "5.0.0"
                ]
            ]
        },
        {
            "name": "pytest-cov",
            "specs": [
                [
                    "==",
                    "6.0.0"
                ]
            ]
        }
    ],
    "lcname": "utm"
}
        
Elapsed time: 0.46771s