Coder Social home page Coder Social logo

avitase / geordpy Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 83 KB

GeoRDPy is a Python library that simplifies geodetic-coordinate polylines using the Ramer-Douglas-Peucker algorithm. It reduces the number of points while preserving accuracy, making it ideal for optimizing geospatial data representations. Specify a threshold for error tolerance and choose a sphere radius for tailored simplification.

License: MIT License

Python 100.00%
polylines python ramer-douglas-peucker-algorithm geospatial great-circle great-circle-distance rhumb-line

geordpy's Introduction

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.

geordpy's People

Contributors

avitase avatar dependabot[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.