Skip to main content

A Python library for simplifying geodetic-coordinate polylines using the Ramer-Douglas-Peucker algorithm

Project description

GeoRDPy

Python 3.10 PyPI Documentation Test coverage Unit tests Code style: black

GeoRDPy is a Python library that simplifies geodetic-coordinate polylines using the Ramer-Douglas-Peucker algorithm. By default, it utilizes the distance to great-circle segments as the distance metric to reduce the number of points in a polyline while maintaining accuracy. Optionally, the segments can be interpolated with rhumb lines instead of great-circle. For both options, the great-circle distance is used internally for finding the smallest distance between the interpolated segment and geodetic-coordinate points.

Installation

GeoRDPy releases are available as wheel packages for macOS, Windows and Linux on PyPI. Install it using pip:

$ pip install geordpy

Example Usage

The GeoRDPy API is designed with simplicity in mind, featuring a single method called geordpy.rdp_filter:

>>> import geordpy
>>> points = [(latitude1, longitude1), (latitude2, longitude2), ...]
>>> threshold = 15_000  # meters
>>> mask = geordpy.rdp_filter(points, threshold)
>>> trajectory = np.array(points)[mask]

For a quick illustration of how to utilize this method, refer to the example here.

For more details, check the documentation.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please feel free to submit a pull request.

Development Setup

To set up your development environment, follow these steps:

  1. Clone the repository:

    $ git clone https://github.com/avitase/geordpy.git
    
  2. Change to the project directory:

    $ cd geordpy
    
  3. Install the development dependencies using pip:

    $ pip install -e .[dev]
    

Pre-Commit-Hooks

To maintain code quality and avoid pushing invalid commits, we recommend using pre-commit hooks. These hooks perform automated checks before commits are made. To set up pre-commit hooks, follow these steps:

  1. Install the pre-commit package (if not already installed):

    $ pip install pre-commit
    
  2. Install the hooks:

    $ pre-commit install
    

Now, each time you commit changes, the pre-commit hooks will run checks such as formatting, linting, and more. If any issues are found, they will be flagged before the commit is made.

Running Tests

You can run tests using the following command:

$ pytest

Make sure to run tests before submitting a pull request to ensure that everything is functioning as expected.

Project details


Download files

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

Source Distribution

geordpy-3.1.tar.gz (26.6 kB view details)

Uploaded Source

Built Distribution

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

geordpy-3.1-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file geordpy-3.1.tar.gz.

File metadata

  • Download URL: geordpy-3.1.tar.gz
  • Upload date:
  • Size: 26.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for geordpy-3.1.tar.gz
Algorithm Hash digest
SHA256 4f4a270de8ab253f29a6e7dc089c9860e07fe13bde002de461452511cc875261
MD5 a38a99c5cd7521eba35a57c43235a49a
BLAKE2b-256 e807d0a104539173e850ccef3da6ef06116367cc8dde37fcad5630b7c3ce0b7a

See more details on using hashes here.

File details

Details for the file geordpy-3.1-py3-none-any.whl.

File metadata

  • Download URL: geordpy-3.1-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for geordpy-3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7673ed18cfd5dcf7d8fdf14ade1d0d9656f273eb04f13ed7b2bdeccc983b2f46
MD5 dd08fa2226d75f97d371410374229863
BLAKE2b-256 69fea22a22e91048918051a56c03e9827db484aaa5c0b03d1dcd815fde78e641

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page