pysnapping


Namepysnapping JSON
Version 0.2.1 PyPI version JSON
download
home_pageNone
SummarySnap points to a line string keeping a given order or spacing intact
upload_time2024-03-28 12:50:27
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT License Copyright (c) 2023 geOps Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords snapping projecting linear referencing order linestring gis gtfs kilometrage dag shortest path
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PySnapping

Snap points to a line string keeping a given order or spacing intact.

The PySnapping python library helps to solve the problem of snapping an ordered sequence of points
to a line string, respecting the given input order.

The motivation for this library is to solve the problem of snapping stops onto vehicle trajectories
in the [GTFS format](https://gtfs.org/) with inaccurate or missing kilometrage.

In order to be able to work with metric parameters and to treat data with large extent located
anywhere on the world, we use the [EPSG:4978](https://epsg.io/4978) Cartesian 3D geocentric coordinate system
for the internal representation.

The library aims to automatically classify kilometrage information as trusted or
untrusted. Trusted points are always snapped as given by the kilometrage. In between
trusted points, untrusted points are snapped by minimizing the sum of square snapping
distances among all admissible solutions within certain radii. Admissible solutions are
those that respect the order and minimum spacing between points.

## Installation

Install the latest stable release from PyPI with pip:

```bash
pip install pysnapping
```

## Modules

### Linear Referencing

The `pysnapping.linear_referencing` module contains low-level classes and functions for referencing points along
linear features in N-dimensions built on top of `numpy`. This contains interpolation/extrapolation along a line string
and data structures optimized for projecting points to substrings of a line string.

### Utils

The `pysnapping.util` module contains common helper functions used in other parts of the library.

### Snapping

The `pysanpping.snap` module is the main entry point for users of the `pysnapping` library and
provides the classes needed to use the library.

## Usage

The typical usage pattern is to create a `pysnapping.snap.DubiousTrajectory` instance which represents
a vehicle trajectory with dubious kilometrage and a `pysnapping.snap.DubiousTrajectoryTrip` `dtrip` which represents
a trip along such a trajectory with dubious kilometrage for the stops.
Then `dtrip.to_trajectory_trip` can be used to get a `pysnapping.snap.TrajectorTrip` `trip` with well defined
metric kilometrage. `trip.trajectory` then refers to a `pysnapping.snap.Trajectory` instance with well defined metric
kilometrage.

The `trip.snap_trip_points` method can be used to snap the trip points onto the
trajectory, resulting in a `pysnapping.snap.SnappedTripPoints` instance `snapped`. Then
you can e.g. split the trajectory at the stops using the
`snapped.get_inter_point_ls_coords_in_travel_direction` method. Snapping can be
controlled with parameters given by a `pysnapping.snap.SnappingParams` instance.

A more detailed usage example (e.g. how to process GTFS input) is planned but not available yet.
Until then, please also check the docstrings and source code for additional usage hints/possibilities.

## Issue Tracker

Please use [the GitHub issue tracker](https://github.com/geops/pysnapping/issues) to report bugs/issues.

## Development

### Contributing

If you want to contribute to the pysnapping library, you can make a pull request at [GitHub](https://github.com/geops/pysnapping).
Before working on major features/changes, please consider contacting us about your plans.
See [our GitHub page](https://github.com/geops) for contact details.

### Editable Installation

Clone this repo and enter the corresponding directory.
Create a virtual environment, then install frozen requirements, dev-requirements
and this library in editable mode:

```bash
python3.9 -m venv env
. env/bin/activate
pip install -U pip
pip install -r requirements.txt -r dev-requirements.txt -e .
```

Keep env activated for all following instructions.

### Pre-Commit Hooks

Enable pre-commit hooks:

```bash
pre-commit install
```

From time to time (not automated yet) run

```bash
pre-commit autoupdate
```

to update frozen revs.

### Run Tests

Run tests and analyze code coverage:

```bash
pytest --cov=pysnapping --cov-report term --cov-fail-under=85 pysnapping
```

## Changelog

### v0.2.0

#### Breaking Changes

* Snapping for untrusted points is now done by an exact algorithm instead of the
  iterative approximate solution. This implies breaking changes to the parameters in
  `snap.SnappingParams` as well as to parts of the API of the classes in the `snap`
  module. For example: Timing information to guide the initial conditions of the
  iterative solution is not necessary and thus not supported any more.
* The `ordering` module has been removed since it is not needed any more.

#### Other Changes:

* The development toolchain now uses ruff where possible.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pysnapping",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "Alexander Held | geOps <alexander.held@geops.com>",
    "keywords": "snapping, projecting, linear referencing, order, linestring, GIS, GTFS, kilometrage, DAG, shortest path",
    "author": null,
    "author_email": "Alexander Held | geOps <alexander.held@geops.com>",
    "download_url": "https://files.pythonhosted.org/packages/5e/8c/c0fb7bf53e0af266113bf53840d3c1d2a993e0e50fff44bfc7fc0ef1bdc4/pysnapping-0.2.1.tar.gz",
    "platform": null,
    "description": "# PySnapping\n\nSnap points to a line string keeping a given order or spacing intact.\n\nThe PySnapping python library helps to solve the problem of snapping an ordered sequence of points\nto a line string, respecting the given input order.\n\nThe motivation for this library is to solve the problem of snapping stops onto vehicle trajectories\nin the [GTFS format](https://gtfs.org/) with inaccurate or missing kilometrage.\n\nIn order to be able to work with metric parameters and to treat data with large extent located\nanywhere on the world, we use the [EPSG:4978](https://epsg.io/4978) Cartesian 3D geocentric coordinate system\nfor the internal representation.\n\nThe library aims to automatically classify kilometrage information as trusted or\nuntrusted. Trusted points are always snapped as given by the kilometrage. In between\ntrusted points, untrusted points are snapped by minimizing the sum of square snapping\ndistances among all admissible solutions within certain radii. Admissible solutions are\nthose that respect the order and minimum spacing between points.\n\n## Installation\n\nInstall the latest stable release from PyPI with pip:\n\n```bash\npip install pysnapping\n```\n\n## Modules\n\n### Linear Referencing\n\nThe `pysnapping.linear_referencing` module contains low-level classes and functions for referencing points along\nlinear features in N-dimensions built on top of `numpy`. This contains interpolation/extrapolation along a line string\nand data structures optimized for projecting points to substrings of a line string.\n\n### Utils\n\nThe `pysnapping.util` module contains common helper functions used in other parts of the library.\n\n### Snapping\n\nThe `pysanpping.snap` module is the main entry point for users of the `pysnapping` library and\nprovides the classes needed to use the library.\n\n## Usage\n\nThe typical usage pattern is to create a `pysnapping.snap.DubiousTrajectory` instance which represents\na vehicle trajectory with dubious kilometrage and a `pysnapping.snap.DubiousTrajectoryTrip` `dtrip` which represents\na trip along such a trajectory with dubious kilometrage for the stops.\nThen `dtrip.to_trajectory_trip` can be used to get a `pysnapping.snap.TrajectorTrip` `trip` with well defined\nmetric kilometrage. `trip.trajectory` then refers to a `pysnapping.snap.Trajectory` instance with well defined metric\nkilometrage.\n\nThe `trip.snap_trip_points` method can be used to snap the trip points onto the\ntrajectory, resulting in a `pysnapping.snap.SnappedTripPoints` instance `snapped`. Then\nyou can e.g. split the trajectory at the stops using the\n`snapped.get_inter_point_ls_coords_in_travel_direction` method. Snapping can be\ncontrolled with parameters given by a `pysnapping.snap.SnappingParams` instance.\n\nA more detailed usage example (e.g. how to process GTFS input) is planned but not available yet.\nUntil then, please also check the docstrings and source code for additional usage hints/possibilities.\n\n## Issue Tracker\n\nPlease use [the GitHub issue tracker](https://github.com/geops/pysnapping/issues) to report bugs/issues.\n\n## Development\n\n### Contributing\n\nIf you want to contribute to the pysnapping library, you can make a pull request at [GitHub](https://github.com/geops/pysnapping).\nBefore working on major features/changes, please consider contacting us about your plans.\nSee [our GitHub page](https://github.com/geops) for contact details.\n\n### Editable Installation\n\nClone this repo and enter the corresponding directory.\nCreate a virtual environment, then install frozen requirements, dev-requirements\nand this library in editable mode:\n\n```bash\npython3.9 -m venv env\n. env/bin/activate\npip install -U pip\npip install -r requirements.txt -r dev-requirements.txt -e .\n```\n\nKeep env activated for all following instructions.\n\n### Pre-Commit Hooks\n\nEnable pre-commit hooks:\n\n```bash\npre-commit install\n```\n\nFrom time to time (not automated yet) run\n\n```bash\npre-commit autoupdate\n```\n\nto update frozen revs.\n\n### Run Tests\n\nRun tests and analyze code coverage:\n\n```bash\npytest --cov=pysnapping --cov-report term --cov-fail-under=85 pysnapping\n```\n\n## Changelog\n\n### v0.2.0\n\n#### Breaking Changes\n\n* Snapping for untrusted points is now done by an exact algorithm instead of the\n  iterative approximate solution. This implies breaking changes to the parameters in\n  `snap.SnappingParams` as well as to parts of the API of the classes in the `snap`\n  module. For example: Timing information to guide the initial conditions of the\n  iterative solution is not necessary and thus not supported any more.\n* The `ordering` module has been removed since it is not needed any more.\n\n#### Other Changes:\n\n* The development toolchain now uses ruff where possible.\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 geOps  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Snap points to a line string keeping a given order or spacing intact",
    "version": "0.2.1",
    "project_urls": {
        "geOps": "https://geops.com/en",
        "homepage": "https://github.com/geops/pysnapping"
    },
    "split_keywords": [
        "snapping",
        " projecting",
        " linear referencing",
        " order",
        " linestring",
        " gis",
        " gtfs",
        " kilometrage",
        " dag",
        " shortest path"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aba7f8d7be0f0d089514aa739c824682098a3cae66fb9cc9832f58f85978b84e",
                "md5": "0bb61ffba49092d6abfea2ffdffd98cb",
                "sha256": "4ec5ab594e885831ca834ed6092ab5a6f18914cc6188e64a0f55dac90d3dc8fd"
            },
            "downloads": -1,
            "filename": "pysnapping-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0bb61ffba49092d6abfea2ffdffd98cb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 38290,
            "upload_time": "2024-03-28T12:50:25",
            "upload_time_iso_8601": "2024-03-28T12:50:25.661030Z",
            "url": "https://files.pythonhosted.org/packages/ab/a7/f8d7be0f0d089514aa739c824682098a3cae66fb9cc9832f58f85978b84e/pysnapping-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5e8cc0fb7bf53e0af266113bf53840d3c1d2a993e0e50fff44bfc7fc0ef1bdc4",
                "md5": "79ede25b66c62b8d64220ec9cf34f9c7",
                "sha256": "3794b2e09560105ec962ce33199a6f4219a21a313808e5f4dfda737a2f634c30"
            },
            "downloads": -1,
            "filename": "pysnapping-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "79ede25b66c62b8d64220ec9cf34f9c7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 41960,
            "upload_time": "2024-03-28T12:50:27",
            "upload_time_iso_8601": "2024-03-28T12:50:27.602050Z",
            "url": "https://files.pythonhosted.org/packages/5e/8c/c0fb7bf53e0af266113bf53840d3c1d2a993e0e50fff44bfc7fc0ef1bdc4/pysnapping-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-28 12:50:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "geops",
    "github_project": "pysnapping",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "pysnapping"
}
        
Elapsed time: 0.26285s