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 Code style: black

GeoRDPy is a Python library that simplifies geodetic-coordinate polylines using the Ramer-Douglas-Peucker algorithm. It utilizes the distance to great circle segments as the distance metric to reduce the number of points in a polyline while maintaining accuracy.

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-2.1.0.tar.gz (24.9 kB view hashes)

Uploaded Source

Built Distribution

geordpy-2.1.0-py3-none-any.whl (6.4 kB view hashes)

Uploaded Python 3

Supported by

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