Calculate the length of a GeoJSON LineString or MultiLineString
Project description
geojson-length
Calculate the length of a GeoJSON LineString or MultiLineString
Installation
$ pip3 install geojson-length
Usage
>>> from geojson_length import calculate_distance, Unit
>>> from geojson import Feature, LineString
>>> line = Feature(geometry=LineString([[19.6929931640625,48.953170117120976],[19.5556640625,48.99283383694351]]))
>>> calculate_distance(line, Unit.meters)
10979.098283583924
Note: You need to install python-geojson first or you can define GeoJSON as python dict:
line = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[
19.6929931640625,
48.953170117120976
],
[
19.5556640625,
48.99283383694351
]
]
}
}
Run test suite
$ pip install pytest
$ poetry run pytest --color=yes --verbose --showlocals tests
You may need to run
poetry install
first.
Credits
This package was created with Cookiecutter_ and the audreyr/cookiecutter-pypackage` project template.
The idea was inspired by geojson-length package written in JS.
License
Free software: MIT license
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
geojson-length-0.3.0.tar.gz
(3.7 kB
view hashes)
Built Distribution
Close
Hashes for geojson_length-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78b82229f7430a6a1f9d6b6a00ff50219686f3d3f8f4a331aac99e53f426c1f7 |
|
MD5 | 2dd0914ea56dc9f368bae511b5bb1991 |
|
BLAKE2b-256 | 218b22ec5cccf74c0b30ff39f0142954c051ba9f9cb443a8dd3c71b08c297e49 |