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.4.0.tar.gz
(3.7 kB
view details)
Built Distribution
File details
Details for the file geojson-length-0.4.0.tar.gz
.
File metadata
- Download URL: geojson-length-0.4.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.8.12 Linux/5.11.0-1028-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5840132e20e68aae5cd0f34b8cb55354603fb914560105b3ff851d0965079a54 |
|
MD5 | e75720781308bbc0c8a539baf37d73cb |
|
BLAKE2b-256 | fda6308d1b54f4a508e6d069f6f6bd922c122b91b11e4f5017a6f0cc1b739c61 |
File details
Details for the file geojson_length-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: geojson_length-0.4.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.8.12 Linux/5.11.0-1028-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b92bb06cd9f64fd3128473f675c9e11fb262957ebe867973d742960833d3d965 |
|
MD5 | 0da9b3a7d095235fab87e107d5d4ae00 |
|
BLAKE2b-256 | 8163405661443e61cf485a9a1314998d13cc4e3c07dcbfd434cf85d79abe1614 |