A simple package for acquiring and manipulating catchments from Skobbler and Here API
Project description
🌍 catchments
Python wrapper for SKOBBLER RealReach and HERE Isolines API. It allows to acquire and manipulate catchments from those APIs.
Installation
$ pip install catchments
Usage
>>> from catchments import SkobblerAPI, HereAPI
>>> # get catchment from Skobbler API
>>> skobbler = SkobblerAPI('your_api_key')
>>> # if you don't provide params values default ones will be used
>>> params = {"range": 600, "highways": 1}
>>> catchment = skobbler.get_catchment({'lat' 52.05, 'lon': 16.82}, **params)
>>> {"realReach": {...} ...}
>>> geojson = skobbler.catchment_as_geojson(catchment)
>>> {"type": "Feature", geometry: {"type": "Polygon", ...}, ...}
>>> skobbler.save_as_geojson(geojson)
>>> 'SKOBBLER_52.05_16.82.geojson'
Params supported by SKOBBLER and HERE:
Skobbler RealReach API params (startMercator, response_type - not supported)
Or You can use inbuilt command line script which accepts *.csv file input with points as coordinates resource. It generates *.geojson files for every point in given *.csv file.
Example *.csv file structure (name column is optional):
name |
lat |
lon |
---|---|---|
point1 |
52.0557 |
16.8278 |
point2 |
52.4639 |
16.9410 |
$ catchments-cls.py -a SKOBBLER -k your_api_key -p path/to/file/with/points/*.csv
All supported options for command line script are mentioned below:
-a –api [REQUIRED] [SKOBBLER AND HERE] - default value is None. You can choose from SKOBBLER or HERE.
-k –key [REQUIRED] [SKOBBLER AND HERE] - default value is None. Format this param like this:
SKOBBLER - “your_api_key”
HERE - “app_id,app_code”
-p –points [REQUIRED] [SKOBBLER AND HERE] - default value is None:
SKOBBLER - path to *.csv file with points
HERE - path to *.csv file with points
-r –range - [OPTIONAL] [SKOBBLER AND HERE] default value is:
SKOBBLER 600
HERE 600
-e –range-type - [OPTIONAL] [HERE ONLY] default value is:
time
-m –mode - [OPTIONAL] [HERE ONLY] default value is:
fastest;car;traffic:disabled
-u –units - [OPTIONAL] [SKOBBLER ONLY] default value is:
sec
-t –transport - [OPTIONAL] [SKOBBLER ONLY] default value is:
car
-l –toll - [OPTIONAL] [SKOBBLER ONLY] default value is:
0
-w –highways - [OPTIONAL] [SKOBBLER ONLY] default value is:
0
-n –non_reachable - [OPTIONAL] [SKOBBLER ONLY] default value is:
0
Tests
$ python setup.py test
TODO
Add support for Mapzen API catchments
Release History
1.0.0 (2017-05-01)
Bug fixes, code reorganization
Better documentation
0.9.1b (2017-03-11)
Required params validation in catchments-cls.py
0.9.0b (2017-03-11)
Initial release (beta)
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
Built Distribution
Hashes for catchments-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2accc8cb8cbd0b90b91db969677876b672daa6e9d62257a393f1dfa1ff13a476 |
|
MD5 | f6d1eee25bf4b631061e441447d87e19 |
|
BLAKE2b-256 | 35034b2dc782a12cefbd90fc89174dae100dd6d397a8c5bc49836ade9f818c76 |