Skip to main content

rasta

PyPI Latest Release PyTest License: MIT Code style: black

Python 3.6+ Python 3.7+ Python 3.8+

Rasta (rāstā) is a Python based library specifically design to handle geospatial data especially in the context of navigation. Currently, one can use rasta to parse/process/visualize GPX, GTFS, GEOJSON data. In addition, there are modules to use REST API from HERE and OpenTripPlanner for the navigation.

Features

  • Parse GPX file and convert them to pandas dataframe in a single line of code. Finally able to visualize the tracks with kepler.gl based interactive map.
  • Parse GTFS feed and visualize the network.
  • Navigate with HERE Maps or OpenTripPlanned by using their respective REST APIs.

Install

Directly install from PyPI:

pip install rasta

Alternatively, clone this repo and install:

git clone https://github.com/ikespand/rasta.git
cd rasta
python setup.py install

To visualize data with the kepler.gl, user needs to have Mapbox API key which provides the tiles. Go to Mapbox.com to get an API key.

Usage

There are many examples available in the example folder. Additionally, code is documented with docstrings.

Using GPX tracks

Examples gpx_bicycle_tracks.py and gpx_dmrc_yellow_line.py show the usage of gpx module for parsing gpx file along with the data processing. For any generic GPX file:

from rasta.gpx import GpxParser
# Load the gpx file (if timestamp is available then also calculate speed)
gpx_instance = GpxParser("../tracks/BicyleRoute.gpx", calculate_distance=True)
# Extract our data in a dataframe
df = gpx_instance.data
# Visaulize the tracks (You will need Mapbox API key for this step)
html_path, vis = gpx_instance.visualize_route(MAPBOX_API_KEY=MAPBOX_API_KEY,open_browser=True)

Using GTFS feed

Example gtfs_sample_london.py is to have the visalization of GTFS feed from a given zip file. For a generic GTFS feed:

from rasta.gtfs import Gtfs
# Parse our GTFS feed
my_gtfs = Gtfs("../tracks/gtfs_london.zip")
# Visaulize the routes (You will need Mapbox API key for this step)
my_gtfs.visualize_route(MAPBOX_API_KEY, "london")

Interaction with REST API of OpenTripPlanner

otp_visualize_from_rest.ipynb is a notebook to demonstrate the usage of OpenTripPlanner's REST API with rasta. Let's say OTP server is ruuning then one could use:

from navigate_with_otp import GetOtpRoute
import pandas as pd
import numpy as np
# Pass arguments for our query along with parameters for visulization
my_otp_nav = GetOtpRoute(start_coord="28.658420, 77.230757", end_coord="28.544442, 77.206334", MAPBOX_API_KEY=MAPBOX_API_KEY, output_map_path="temporary_map", viz=False)
my_otp_nav.address
gdf, html_path = my_otp_nav.extract_itinerary()

Troubleshooting and some hints

  • With keplergl>0.2.1 auto-centering for map data is not working (i.e. you will see San Frasnico as default). Therefore, if you face this issue then consider to downgrade to v0.2.0.
  • Sometime, the issue of geopandas, fiona and GDAL appears due to some inter-dependencies. To mitigate it, simply uninstall all 3 and use conda forge to install geopandas.
  • If you are new to OTP, then try using docker solution which is documented here.

TODO

  • Support for OpenStreetMap data coming from overpy
  • GTFS validator
  • More tests
  • Extend documentation

Developed at: KLabs_logo

Metadata

Release files for rasta 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rasta 0.0.4
File Size Uploaded Provenance Actions
rasta-0.0.4.tar.gz 16.2 kB Without provenance Details for rasta-0.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rasta 0.0.4
File Interpreter ABI Platform Actions
rasta-0.0.4-py3-none-any.whl Python 3 none any Details for rasta-0.0.4-py3-none-any.whl

Total release size: 31.3 kB

Release files / rasta-0.0.4.tar.gz

Download URL rasta-0.0.4.tar.gz
Size 16.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d150a1423db39f29b74a7bf7faf3773a0c7371c9c036e78380c2e1691b83eead
BLAKE2b-256 checksum
How to use checksums
7b405772f25b810b7f6070442075441df4ea170844cd02fbbc1fe1a7338882b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.4

Release files / rasta-0.0.4-py3-none-any.whl

Download URL rasta-0.0.4-py3-none-any.whl
Size 15.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
345c677a6824617af7379b62572ffc38387c9bb9e4306d51305e4bcb7b38953a
BLAKE2b-256 checksum
How to use checksums
14d4df193923ca6933c31a7e93608d700de0bce6add21e705e26b561e084548d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.4

Security for rasta 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page