karney


Namekarney JSON
Version 1.0.10 PyPI version JSON
download
home_pageNone
SummarySolves the direct and inverse geodesic problem.
upload_time2024-09-30 12:13:40
maintainerNone
docs_urlNone
authorPer A. Brodtkorb
requires_python>=3.8.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Introduction to Karney

[![PyPI version](https://badge.fury.io/py/karney.svg)](https://badge.fury.io/py/karney)
[![Documentation](https://readthedocs.org/projects/karney/badge/?svg=true "documentation")](https://karney.readthedocs.io/en/latest/)
[![CI-tests](https://github.com/pbrod/karney/actions/workflows/CI-CD.yml/badge.svg)](https://github.com/pbrod/karney/actions/workflows/CI-CD.yml)


The `karney` library provides native Python implementations of a subset of the C++ library, GeographicLib.
Currently the following operations are implemented:

* Calculate the surface distance between two geographical positions.

* Find the destination point given start point, azimuth/bearing and distance.


All the functions are vectorized and offer speeds comparable to compiled C++ code when operating on arrays.

Some common features of these functions:

Angles (latitude, longitude, azimuth) are measured in degrees or radians.
Distances are measured in meters.
The ellipsoid is specified as [a, f], where a = equatorial radius and f = flattening.
Keep |f| <= 1/50 for full double precision accuracy.


## Installation

```bash
$ pip install karney
```


## Usage

Below the solution to two geodesic problems are given.

### Surface distance
Find the surface distance sAB (i.e. great circle distance) between two
positions A and B. The heights of A and B are ignored, i.e. if they don't have
zero height, we seek the distance between the points that are at the surface of
the Earth, directly above/below A and B.  Use Earth radius 6371e3 m.
Compare the results with exact calculations for the WGS-84 ellipsoid.

In geodesy this is known as "The second geodetic problem" or
"The inverse geodetic problem" for a sphere/ellipsoid.


Solution for a sphere:

    >>> import numpy as np
    >>> from karney.geodesic import rad, sphere_distance_rad, distance

    >>> latlon_a = (88, 0)
    >>> latlon_b = (89, -170)
    >>> latlons = latlon_a + latlon_b
    >>> r_Earth = 6371e3  # m, mean Earth radius
    >>> s_AB = sphere_distance_rad(*rad(latlons))[0]*r_Earth
    >>> s_AB = distance(*latlons, a=r_Earth, f=0, degrees=True)[0] # or alternatively

    >>> 'Ex5: Great circle = {:5.2f} km'.format(s_AB / 1000)
    'Ex5: Great circle = 332.46 km'

Exact solution for the WGS84 ellipsoid:

    >>> s_12, azi1, azi2 = distance(*latlons, degrees=True)
    >>> 'Ellipsoidal distance = {:5.2f} km'.format(s_12 / 1000)
    'Ellipsoidal distance = 333.95 km'

See also
    [Example 5 at www.navlab.net](http://www.navlab.net/nvector/#example_5)


### A and azimuth/distance to B

We have an initial position A, direction of travel given as an azimuth
(bearing) relative to north (clockwise), and finally the
distance to travel along a great circle given as sAB.
Use Earth radius 6371e3 m to find the destination point B.

In geodesy this is known as "The first geodetic problem" or
"The direct geodetic problem" for a sphere.


    >>> import numpy as np
    >>> from karney.geodesic import reckon
    >>> lat, lon = 80, -90
    >>> msg = 'Ex8, Destination: lat, lon = {:4.4f} deg, {:4.4f} deg'

Greatcircle solution:

    >>> lat2, lon2, azi_b = reckon(lat, lon, distance=1000, azimuth=200, a=6371e3, f=0, degrees=True)

    >>> msg.format(lat2, lon2)
    'Ex8, Destination: lat, lon = 79.9915 deg, -90.0177 deg'

    >>> np.allclose(azi_b, -160.0174292682187)
    True

Exact solution:

    >>> lat_b, lon_b, azi_b = reckon(lat, lon, distance=1000, azimuth=200, degrees=True)
    >>> msg.format(lat_b, lon_b)
    'Ex8, Destination: lat, lon = 79.9916 deg, -90.0176 deg'

    >>> np.allclose(azi_b, -160.01742926820506)
    True


See also
    [Example 8 at www.navlab.net](http://www.navlab.net/nvector/#example_8)

	

## Contributing

Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.

## License

`karney` was created by Per A. Brodtkorb and is licensed under the terms of the MIT/X11 license.


## Acknowledgements

The [`karney` package](http://pypi.python.org/pypi/karney/) for
[Python](https://www.python.org/) was written by Per A. Brodtkorb at
[FFI (The Norwegian Defence Research Establishment)](http://www.ffi.no/en>)
based on the [Geographic toolbox](https://github.com/geographiclib/geographiclib-octave)
written by Charles Karney for [Matlab](http://www.mathworks.com) and [GNU Octave](https://octave.org>).
The karney.geodesic module is a vectorized reimplementation of the Matlab/Octave GeographicLib toolbox.

The content is based on the article by [Karney, 2013](https://doi.org/10.1007/s00190-012-0578-z).
Thus this article should be cited in publications using the software.



The `karney` package structure was created with [`cookiecutter`](https://cookiecutter.readthedocs.io/en/latest/) and the `py-pkgs-cookiecutter` [template](https://github.com/py-pkgs/py-pkgs-cookiecutter).


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "karney",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8.0",
    "maintainer_email": null,
    "keywords": null,
    "author": "Per A. Brodtkorb",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/19/2b/14ad086fa0caf46a31990d74214b3122c94577040ca2498094009ceddf0b/karney-1.0.10.tar.gz",
    "platform": null,
    "description": "# Introduction to Karney\n\n[![PyPI version](https://badge.fury.io/py/karney.svg)](https://badge.fury.io/py/karney)\n[![Documentation](https://readthedocs.org/projects/karney/badge/?svg=true \"documentation\")](https://karney.readthedocs.io/en/latest/)\n[![CI-tests](https://github.com/pbrod/karney/actions/workflows/CI-CD.yml/badge.svg)](https://github.com/pbrod/karney/actions/workflows/CI-CD.yml)\n\n\nThe `karney` library provides native Python implementations of a subset of the C++ library, GeographicLib.\nCurrently the following operations are implemented:\n\n* Calculate the surface distance between two geographical positions.\n\n* Find the destination point given start point, azimuth/bearing and distance.\n\n\nAll the functions are vectorized and offer speeds comparable to compiled C++ code when operating on arrays.\n\nSome common features of these functions:\n\nAngles (latitude, longitude, azimuth) are measured in degrees or radians.\nDistances are measured in meters.\nThe ellipsoid is specified as [a, f], where a = equatorial radius and f = flattening.\nKeep |f| <= 1/50 for full double precision accuracy.\n\n\n## Installation\n\n```bash\n$ pip install karney\n```\n\n\n## Usage\n\nBelow the solution to two geodesic problems are given.\n\n### Surface distance\nFind the surface distance sAB (i.e. great circle distance) between two\npositions A and B. The heights of A and B are ignored, i.e. if they don't have\nzero height, we seek the distance between the points that are at the surface of\nthe Earth, directly above/below A and B.  Use Earth radius 6371e3 m.\nCompare the results with exact calculations for the WGS-84 ellipsoid.\n\nIn geodesy this is known as \"The second geodetic problem\" or\n\"The inverse geodetic problem\" for a sphere/ellipsoid.\n\n\nSolution for a sphere:\n\n    >>> import numpy as np\n    >>> from karney.geodesic import rad, sphere_distance_rad, distance\n\n    >>> latlon_a = (88, 0)\n    >>> latlon_b = (89, -170)\n    >>> latlons = latlon_a + latlon_b\n    >>> r_Earth = 6371e3  # m, mean Earth radius\n    >>> s_AB = sphere_distance_rad(*rad(latlons))[0]*r_Earth\n    >>> s_AB = distance(*latlons, a=r_Earth, f=0, degrees=True)[0] # or alternatively\n\n    >>> 'Ex5: Great circle = {:5.2f} km'.format(s_AB / 1000)\n    'Ex5: Great circle = 332.46 km'\n\nExact solution for the WGS84 ellipsoid:\n\n    >>> s_12, azi1, azi2 = distance(*latlons, degrees=True)\n    >>> 'Ellipsoidal distance = {:5.2f} km'.format(s_12 / 1000)\n    'Ellipsoidal distance = 333.95 km'\n\nSee also\n    [Example 5 at www.navlab.net](http://www.navlab.net/nvector/#example_5)\n\n\n### A and azimuth/distance to B\n\nWe have an initial position A, direction of travel given as an azimuth\n(bearing) relative to north (clockwise), and finally the\ndistance to travel along a great circle given as sAB.\nUse Earth radius 6371e3 m to find the destination point B.\n\nIn geodesy this is known as \"The first geodetic problem\" or\n\"The direct geodetic problem\" for a sphere.\n\n\n    >>> import numpy as np\n    >>> from karney.geodesic import reckon\n    >>> lat, lon = 80, -90\n    >>> msg = 'Ex8, Destination: lat, lon = {:4.4f} deg, {:4.4f} deg'\n\nGreatcircle solution:\n\n    >>> lat2, lon2, azi_b = reckon(lat, lon, distance=1000, azimuth=200, a=6371e3, f=0, degrees=True)\n\n    >>> msg.format(lat2, lon2)\n    'Ex8, Destination: lat, lon = 79.9915 deg, -90.0177 deg'\n\n    >>> np.allclose(azi_b, -160.0174292682187)\n    True\n\nExact solution:\n\n    >>> lat_b, lon_b, azi_b = reckon(lat, lon, distance=1000, azimuth=200, degrees=True)\n    >>> msg.format(lat_b, lon_b)\n    'Ex8, Destination: lat, lon = 79.9916 deg, -90.0176 deg'\n\n    >>> np.allclose(azi_b, -160.01742926820506)\n    True\n\n\nSee also\n    [Example 8 at www.navlab.net](http://www.navlab.net/nvector/#example_8)\n\n\t\n\n## Contributing\n\nInterested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.\n\n## License\n\n`karney` was created by Per A. Brodtkorb and is licensed under the terms of the MIT/X11 license.\n\n\n## Acknowledgements\n\nThe [`karney` package](http://pypi.python.org/pypi/karney/) for\n[Python](https://www.python.org/) was written by Per A. Brodtkorb at\n[FFI (The Norwegian Defence Research Establishment)](http://www.ffi.no/en>)\nbased on the [Geographic toolbox](https://github.com/geographiclib/geographiclib-octave)\nwritten by Charles Karney for [Matlab](http://www.mathworks.com) and [GNU Octave](https://octave.org>).\nThe karney.geodesic module is a vectorized reimplementation of the Matlab/Octave GeographicLib toolbox.\n\nThe content is based on the article by [Karney, 2013](https://doi.org/10.1007/s00190-012-0578-z).\nThus this article should be cited in publications using the software.\n\n\n\nThe `karney` package structure was created with [`cookiecutter`](https://cookiecutter.readthedocs.io/en/latest/) and the `py-pkgs-cookiecutter` [template](https://github.com/py-pkgs/py-pkgs-cookiecutter).\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Solves the direct and inverse geodesic problem.",
    "version": "1.0.10",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1a2fd7f83ea2edf3b39ffefb9072e7082c8947f0c17bf4891e6ad9b1dee6ddae",
                "md5": "3f6c9e774af795f173711dddfcd56965",
                "sha256": "0d7379b06295a3ffc9b9204e0d426e659057f3e5ab997c463f5b2132502c9826"
            },
            "downloads": -1,
            "filename": "karney-1.0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3f6c9e774af795f173711dddfcd56965",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.0",
            "size": 17769,
            "upload_time": "2024-09-30T12:13:39",
            "upload_time_iso_8601": "2024-09-30T12:13:39.068791Z",
            "url": "https://files.pythonhosted.org/packages/1a/2f/d7f83ea2edf3b39ffefb9072e7082c8947f0c17bf4891e6ad9b1dee6ddae/karney-1.0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "192b14ad086fa0caf46a31990d74214b3122c94577040ca2498094009ceddf0b",
                "md5": "55614e10cabf77eb0ae2f8dbca2785b0",
                "sha256": "e178e24d0941231b1ca062bf677becdd5632b1878bf4369a65b6f88cc3f85f3d"
            },
            "downloads": -1,
            "filename": "karney-1.0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "55614e10cabf77eb0ae2f8dbca2785b0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.0",
            "size": 17427,
            "upload_time": "2024-09-30T12:13:40",
            "upload_time_iso_8601": "2024-09-30T12:13:40.362368Z",
            "url": "https://files.pythonhosted.org/packages/19/2b/14ad086fa0caf46a31990d74214b3122c94577040ca2498094009ceddf0b/karney-1.0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-30 12:13:40",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "karney"
}
        
Elapsed time: 1.94870s