geodistpy


Namegeodistpy JSON
Version 0.1.2 PyPI version JSON
download
home_page
SummaryFor fast geodesic calculations
upload_time2023-09-18 16:45:46
maintainer
docs_urlNone
authorPawan
requires_python>=3.8.1,<3.12
licenseMIT
keywords geodesic harvesine
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Geodistpy: Fast and Accurate Geospatial Distance Computations

[![pypi](https://img.shields.io/pypi/v/geodistpy?label=PyPI&logo=PyPI&logoColor=white&color=blue)](https://pypi.python.org/pypi/geodistpy)
[![lint](https://github.com/pawangeek/geodistpy/actions/workflows/lint.yml/badge.svg)](https://github.com/pawangeek/geodistpy/actions/workflows/lint.yml)
[![Build status](https://ci.appveyor.com/api/projects/status/iqux1vla5rm8bi8r?svg=true)](https://ci.appveyor.com/project/pawangeek/geodistpy)
[![Github Build](https://github.com/pawangeek/geodistpy/actions/workflows/publish_github.yml/badge.svg)](https://github.com/pawangeek/geodistpy/actions/workflows/publish_github.yml)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/geodistpy?label=Python&logo=Python&logoColor=white)
![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)

Geodistpy is a powerful Python library designed for lightning-fast geospatial distance computations. In this README, we'll compare Geodistpy with two other popular libraries, Geopy and Geographiclib, to highlight the significant performance advantages of Geodistpy.

* Documentation: https://pawangeek.github.io/geodistpy/
* Github Repo: https://github.com/pawangeek/geodistpy
* PyPI: https://pypi.org/project/geodistpy/

## Speed Comparison

```python
# Import libraries
from geopy.distance import geodesic as geodesic_geopy
from geographiclib.geodesic import Geodesic as geodesic_gglib
from geokernels.geodesics import geodesic_vincenty

# Define two coordinates
coord1 = (52.5200, 13.4050)  # Berlin
coord2 = (48.8566, 2.3522)   # Paris

# Calculate distance with Geopy (based on Geographiclib)
distance_geopy = geodesic_geopy(coord1, coord2).meters

# Calculate distance with Geographiclib
distance_gglib = geodesic_gglib.WGS84.Inverse(coord1[0], coord1[1], coord2[0], coord2[1])['s12']

# Calculate distance with Geokernels
distance_geokernels = geodesic_vincenty(coord1, coord2)

# Print the results
print(f"Distance between Berlin and Paris:")
print(f"Geopy: {distance_geopy} meters")
print(f"Geographiclib: {distance_gglib} meters")
print(f"Geokernels: {distance_geokernels} meters")
```

We conducted a speed comparison between Geodistpy, Geopy, and Geographiclib using 1000 random samples of coordinates (latitude and longitude). The goal was to calculate all pairwise distances between these coordinates.

### Geopy (Geodesic from Geographiclib)

- Computation Time: Approximately 53.356 seconds
- Accuracy: Comparable to Geographiclib
- Geopy is widely known but relatively slow for distance calculations.

### Geographiclib

- Computation Time: Approximately 36.824 seconds
- Accuracy: High
- Geographiclib is established but still lags in terms of speed.

### Geodistpy (Accelerated Vincenty's Inverse)

- Computation Time: Approximately 0.701 seconds (initial run, including Numba compilation) and 0.393 seconds (subsequent runs)
- Accuracy: High, comparable to Geographiclib
- Geodistpy uses an optimized Vincenty's Inverse method for blazingly fast distance calculations.

## Performance Comparison

- Geodistpy is 78 to 142 times faster than Geopy.
- Geodistpy is 53 to 94 times faster than Geographiclib.

## Context and Background

The Python package `geodistpy` is a versatile library designed for geospatial calculations involving distances between geographical coordinates. It is built on the principles of geodesy and uses the WGS 84 coordinate system, which is commonly used in GPS and mapping applications.

## Why it was Created

The package was created to simplify and standardize geospatial distance calculations. Geographical distance calculations can be complex due to the curvature of the Earth's surface, and this library abstracts away those complexities, allowing users to focus on their specific geospatial tasks.

## Examples and Approaches

Let's explore multiple examples and approaches to working with the `geodistpy` library:

### Example 1: Calculating Distance Between Two Coordinates

```python
from geodistpy import geodist

# Define two coordinates in (latitude, longitude) format
coord1 = (52.5200, 13.4050)  # Berlin, Germany
coord2 = (48.8566, 2.3522)   # Paris, France

# Calculate the distance between the two coordinates in kilometers
distance_km = geodist(coord1, coord2, metric='km')
print(f"Distance between Berlin and Paris: {distance_km} kilometers")
```

### Example 2: Calculating Distance Between Multiple Coordinates

```python
from geodistpy import greatcircle_matrix

# Define a list of coordinates
coords = [(52.5200, 13.4050), (48.8566, 2.3522), (37.7749, -122.4194)]

# Calculate the distance matrix between all pairs of coordinates in miles
distance_matrix_miles = greatcircle_matrix(coords, metric='mile')
print("Distance matrix in miles:")
print(distance_matrix_miles)
```

### Example 3: Working with Different Metrics

The `geodistpy` library allows you to work with various distance metrics, such as meters, kilometers, miles, and nautical miles. You can easily switch between them by specifying the `metric` parameter.

```python
from geodistpy import geodist

coord1 = (52.5200, 13.4050)  # Berlin, Germany
coord2 = (48.8566, 2.3522)   # Paris, France

# Calculate the distance in meters
distance_meters = geodist(coord1, coord2, metric='meter')

# Calculate the distance in nautical miles
distance_nautical_miles = geodist(coord1, coord2, metric='nmi')

print(f"Distance in meters: {distance_meters}")
print(f"Distance in nautical miles: {distance_nautical_miles}")
```

## Conclusion

For applications that demand rapid and precise geospatial distance computations, Geodistpy is the clear choice. It offers exceptional speed improvements over both Geopy and Geographiclib, making it ideal for tasks involving large datasets or real-time geospatial applications. Despite its speed, Geodistpy maintains accuracy on par with Geographiclib, ensuring that fast calculations do not compromise precision.

By adopting Geodistpy, you can significantly enhance the efficiency and performance of your geospatial projects. It is a valuable tool for geospatial professionals and developers seeking both speed and accuracy in their distance computations.

To get started with Geodistpy, visit the [Geodistpy](https://github.com/pawangeek/geodistpy) and explore the documentation for comprehensive usage instructions.


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "geodistpy",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8.1,<3.12",
    "maintainer_email": "",
    "keywords": "geodesic,harvesine",
    "author": "Pawan",
    "author_email": "pawanjain.432@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/9e/ec/1b0cb5c53e98109be2ce461cddb3d0237f8dca5bea1d6f140280ce474bb5/geodistpy-0.1.2.tar.gz",
    "platform": null,
    "description": "# Geodistpy: Fast and Accurate Geospatial Distance Computations\n\n[![pypi](https://img.shields.io/pypi/v/geodistpy?label=PyPI&logo=PyPI&logoColor=white&color=blue)](https://pypi.python.org/pypi/geodistpy)\n[![lint](https://github.com/pawangeek/geodistpy/actions/workflows/lint.yml/badge.svg)](https://github.com/pawangeek/geodistpy/actions/workflows/lint.yml)\n[![Build status](https://ci.appveyor.com/api/projects/status/iqux1vla5rm8bi8r?svg=true)](https://ci.appveyor.com/project/pawangeek/geodistpy)\n[![Github Build](https://github.com/pawangeek/geodistpy/actions/workflows/publish_github.yml/badge.svg)](https://github.com/pawangeek/geodistpy/actions/workflows/publish_github.yml)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/geodistpy?label=Python&logo=Python&logoColor=white)\n![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)\n\nGeodistpy is a powerful Python library designed for lightning-fast geospatial distance computations. In this README, we'll compare Geodistpy with two other popular libraries, Geopy and Geographiclib, to highlight the significant performance advantages of Geodistpy.\n\n* Documentation: https://pawangeek.github.io/geodistpy/\n* Github Repo: https://github.com/pawangeek/geodistpy\n* PyPI: https://pypi.org/project/geodistpy/\n\n## Speed Comparison\n\n```python\n# Import libraries\nfrom geopy.distance import geodesic as geodesic_geopy\nfrom geographiclib.geodesic import Geodesic as geodesic_gglib\nfrom geokernels.geodesics import geodesic_vincenty\n\n# Define two coordinates\ncoord1 = (52.5200, 13.4050)  # Berlin\ncoord2 = (48.8566, 2.3522)   # Paris\n\n# Calculate distance with Geopy (based on Geographiclib)\ndistance_geopy = geodesic_geopy(coord1, coord2).meters\n\n# Calculate distance with Geographiclib\ndistance_gglib = geodesic_gglib.WGS84.Inverse(coord1[0], coord1[1], coord2[0], coord2[1])['s12']\n\n# Calculate distance with Geokernels\ndistance_geokernels = geodesic_vincenty(coord1, coord2)\n\n# Print the results\nprint(f\"Distance between Berlin and Paris:\")\nprint(f\"Geopy: {distance_geopy} meters\")\nprint(f\"Geographiclib: {distance_gglib} meters\")\nprint(f\"Geokernels: {distance_geokernels} meters\")\n```\n\nWe conducted a speed comparison between Geodistpy, Geopy, and Geographiclib using 1000 random samples of coordinates (latitude and longitude). The goal was to calculate all pairwise distances between these coordinates.\n\n### Geopy (Geodesic from Geographiclib)\n\n- Computation Time: Approximately 53.356 seconds\n- Accuracy: Comparable to Geographiclib\n- Geopy is widely known but relatively slow for distance calculations.\n\n### Geographiclib\n\n- Computation Time: Approximately 36.824 seconds\n- Accuracy: High\n- Geographiclib is established but still lags in terms of speed.\n\n### Geodistpy (Accelerated Vincenty's Inverse)\n\n- Computation Time: Approximately 0.701 seconds (initial run, including Numba compilation) and 0.393 seconds (subsequent runs)\n- Accuracy: High, comparable to Geographiclib\n- Geodistpy uses an optimized Vincenty's Inverse method for blazingly fast distance calculations.\n\n## Performance Comparison\n\n- Geodistpy is 78 to 142 times faster than Geopy.\n- Geodistpy is 53 to 94 times faster than Geographiclib.\n\n## Context and Background\n\nThe Python package `geodistpy` is a versatile library designed for geospatial calculations involving distances between geographical coordinates. It is built on the principles of geodesy and uses the WGS 84 coordinate system, which is commonly used in GPS and mapping applications.\n\n## Why it was Created\n\nThe package was created to simplify and standardize geospatial distance calculations. Geographical distance calculations can be complex due to the curvature of the Earth's surface, and this library abstracts away those complexities, allowing users to focus on their specific geospatial tasks.\n\n## Examples and Approaches\n\nLet's explore multiple examples and approaches to working with the `geodistpy` library:\n\n### Example 1: Calculating Distance Between Two Coordinates\n\n```python\nfrom geodistpy import geodist\n\n# Define two coordinates in (latitude, longitude) format\ncoord1 = (52.5200, 13.4050)  # Berlin, Germany\ncoord2 = (48.8566, 2.3522)   # Paris, France\n\n# Calculate the distance between the two coordinates in kilometers\ndistance_km = geodist(coord1, coord2, metric='km')\nprint(f\"Distance between Berlin and Paris: {distance_km} kilometers\")\n```\n\n### Example 2: Calculating Distance Between Multiple Coordinates\n\n```python\nfrom geodistpy import greatcircle_matrix\n\n# Define a list of coordinates\ncoords = [(52.5200, 13.4050), (48.8566, 2.3522), (37.7749, -122.4194)]\n\n# Calculate the distance matrix between all pairs of coordinates in miles\ndistance_matrix_miles = greatcircle_matrix(coords, metric='mile')\nprint(\"Distance matrix in miles:\")\nprint(distance_matrix_miles)\n```\n\n### Example 3: Working with Different Metrics\n\nThe `geodistpy` library allows you to work with various distance metrics, such as meters, kilometers, miles, and nautical miles. You can easily switch between them by specifying the `metric` parameter.\n\n```python\nfrom geodistpy import geodist\n\ncoord1 = (52.5200, 13.4050)  # Berlin, Germany\ncoord2 = (48.8566, 2.3522)   # Paris, France\n\n# Calculate the distance in meters\ndistance_meters = geodist(coord1, coord2, metric='meter')\n\n# Calculate the distance in nautical miles\ndistance_nautical_miles = geodist(coord1, coord2, metric='nmi')\n\nprint(f\"Distance in meters: {distance_meters}\")\nprint(f\"Distance in nautical miles: {distance_nautical_miles}\")\n```\n\n## Conclusion\n\nFor applications that demand rapid and precise geospatial distance computations, Geodistpy is the clear choice. It offers exceptional speed improvements over both Geopy and Geographiclib, making it ideal for tasks involving large datasets or real-time geospatial applications. Despite its speed, Geodistpy maintains accuracy on par with Geographiclib, ensuring that fast calculations do not compromise precision.\n\nBy adopting Geodistpy, you can significantly enhance the efficiency and performance of your geospatial projects. It is a valuable tool for geospatial professionals and developers seeking both speed and accuracy in their distance computations.\n\nTo get started with Geodistpy, visit the [Geodistpy](https://github.com/pawangeek/geodistpy) and explore the documentation for comprehensive usage instructions.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "For fast geodesic calculations",
    "version": "0.1.2",
    "project_urls": null,
    "split_keywords": [
        "geodesic",
        "harvesine"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "be2e32f3fcde523710bf531e8d88f647c52b68c96761159fd478e2f22acaf318",
                "md5": "3695ba18fe9c65081b7386bd69b45bfd",
                "sha256": "b21fb18f5884c2b274ca42ee7f18e7d09729d06b9223f3538eaefb1bdd2336af"
            },
            "downloads": -1,
            "filename": "geodistpy-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3695ba18fe9c65081b7386bd69b45bfd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.1,<3.12",
            "size": 10877,
            "upload_time": "2023-09-18T16:45:45",
            "upload_time_iso_8601": "2023-09-18T16:45:45.251078Z",
            "url": "https://files.pythonhosted.org/packages/be/2e/32f3fcde523710bf531e8d88f647c52b68c96761159fd478e2f22acaf318/geodistpy-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9eec1b0cb5c53e98109be2ce461cddb3d0237f8dca5bea1d6f140280ce474bb5",
                "md5": "1495ed98877da98525f2777040264aa3",
                "sha256": "a8ef987ca0a0e21ecbbf7923df9414ce99a0fbd99515d3df6a7629c812886d5b"
            },
            "downloads": -1,
            "filename": "geodistpy-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "1495ed98877da98525f2777040264aa3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.1,<3.12",
            "size": 11533,
            "upload_time": "2023-09-18T16:45:46",
            "upload_time_iso_8601": "2023-09-18T16:45:46.738037Z",
            "url": "https://files.pythonhosted.org/packages/9e/ec/1b0cb5c53e98109be2ce461cddb3d0237f8dca5bea1d6f140280ce474bb5/geodistpy-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-18 16:45:46",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "geodistpy"
}
        
Elapsed time: 0.17267s