Skip to content

General Transit Feed Specification (GTFS) data into GeoJSON format. To facilitate the integration of public transportation data into geospatial analyses, visualizations, and scientific models. In the context of SUM project, within INRIA and INOCS team.

Notifications You must be signed in to change notification settings

INRIA/inocs-sum-gtfs-geojson

Repository files navigation

Introduction sum_gtfs_geojson

The library sum_gtfs_geojson aims to facilitate the experimentation with Living Labs data within the context of SUM project. The data used within the repository is publicly available by public transport providers.

Features

The library proposes the following features :

  • load public transport network data for a Living Lab
  • create hexagonal grid for the network
  • restrict the perimerer to a given radius in KM
  • restrict the perimeter within the country (ignore stops in neighbouring countries)
  • convert data to GeoJson
  • Demo to display data in map, with HTML/JS and Leaflet library for map display
  • Living Lab available : GENEVA

Documentation

How to use

Install the package

In Python environment, it is a good practice to isolate your project in an environment. The following documentation uses pipenv to handle packages installation the local environment.

Download the built package available at the dist folder.

Then install from local file.

Install from local file :

pipenv install $PATH_TO_FILE/sum_gtfs_geojson-0.1.0-cp39-cp39-macosx_10_9_universal2.whl

Or install from Github link :

pipenv install https://inria.github.io/inocs-sum-gtfs-geojson/dist/sum_gtfs_geojson-0.1.0-cp39-cp39-macosx_10_9_universal2.whl

Run the data manager

Instantiate the class SharedMobilityManager with the desired configuration.

Refer to API documentation sum_gtfs_geojson for full details on the parameters and full data classes data.

NOTE: only the items specified in the data_types list will be included. If data_types is None, then all data items are generated by default.

from sum_gtfs_geojson import SharedMobilityManager, LivingLabsCity, DataType

data_manager = SharedMobilityManager(city=LivingLabsCity.GENEVA,
                                       data_types=[
                                           DataType.ITINERARIES,
                                           DataType.STOPS,
                                           DataType.BIKE_STATIONS,
                                           DataType.BIKE_TRIPS,
                                           DataType.HEX_GRID
                                       ],
                                       restrict_country_boundaries=True,
                                       distance_radius_km=10,
                                       grid_resolution=8
                                       )

To access the data, retrieve from the manager. The data is within a UrbanMobilitySystem class.

gva_data = data_manager.get_data()
pt_stops = gva_data.public_transport.stops
print(f"There are {len(pt_stops)} stops in the dataset")

pt_lines_itineraries = gva_data.public_transport.itineraries
print(f"There are {len(pt_lines_itineraries)} itineraries in the dataset")

pt_ridership = gva_data.ridership
print(f"There are {len(pt_ridership)} ridership records in the dataset")

bike_stations = gva_data.bike_stations
print(f"There are {len(bike_stations)} bike stations in the dataset")

bike_trips = gva_data.bike_trips
print(f"There are {len(bike_trips)} bike trips in the dataset")

hex_grid_cells = gva_data.hex_grid.cells
print(f"There are {len(hex_grid_cells)} hexagons in the dataset")

Finally, you can save the results in geojson files. These geojson files can then be used as input with GeoPandas library

# Save the data to GeoJSON files, specifying the output directory as argument
gva_data.save_to_geojson("my/folder")

You will find the geojson files for every data started by the manager in specified folder my/folder

How to contribute

Build and publish the package

1. Install dependencies and build package

Create environment and install pipenv, then install dependencies. Finally, build the package.

python3 -m venv env && source env/bin/activate && pip install pipenv && pipenv install --dev
# Build the wheel
python -m build

# Generate the docs
python build_docs.py

# OPTIONAL : clean and reset the build files 
rm -rf build dist *.egg-info

The compiled wheel package .whl file will be at ./dist folder.

The documentation will be at ./docs folder.

Local installation for development

Ensure you have Python installed (recommended: Python 3.8+).

  1. Clone the repository
  2. Create an environment
  3. Install the necessary packages
  4. Create experiments and run the models
  5. Analyze the results

1. Clone the repository

Clone the repository using the following command:

git clone https://github.com/INRIA/inocs-sum-gtfs-geojson.git

2. Create an environment

Check the Python packaging user guide for more information on how to manage dependencies in Python.

On Debian protected environment, create a virtual enviornment first :

python3 -m venv env && source env/bin/activate && pip install pipenv

Install library pipenv to handle the environment and the dependencies.

pip install pipenv

View the dynamic map with generated data

Start server with python

python -m http.server 8080 

Then go to page in browser : http://localhost:8080

About

General Transit Feed Specification (GTFS) data into GeoJSON format. To facilitate the integration of public transportation data into geospatial analyses, visualizations, and scientific models. In the context of SUM project, within INRIA and INOCS team.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published