This project is designed to generate a SpatioTemporal Asset Catalog (STAC) from an archive of STAC data. It is specifically tailored to work with Strava archives.
To install the required packages, run the following:
pip install -r requirements.txt
Before running this project, you need to obtain an archive from Strava. This approach was favored over the Strava API due to the cumbersome OAuth2 procedures requiring refresh tokens.
Follow these steps to download your Strava archive:
- Go to the Strava website
- Navigate to 'Settings'
- Under the 'My Account' tab, find the 'Download or Delete Your Account' section
- Click on 'Get Started' under 'Download Request'
- Follow the steps to download your data
Once you have downloaded the archive, unzip it and note the directory as you will need to pass it to the CLI.
The Strava archive provides a CSV file (activities.csv
) that contains metadata for each activity. This metadata is mapped to the STAC catalog to enrich the information available for each spatiotemporal asset.
To generate a STAC catalog, run the following command:
python src/main.py [path_to_strava_archive] [path_to_activities_directory] [path_to_collection_json] [path_to_catalog_json]
Given a PgSTAC database is available and configured, you can ingest your newly generated static catalog with a few commands.
- Generate a newline delimited JSON file of all the items:
python src/newline_items.py [path_to_catalog_json]
- Load collection to PgSTAC:
pypgstac load collections ~/Documents/stac-strava/zac-strava/activities/strava/collection.json --dsn postgresql://username:password@localhost:5439/postgis --method upsert
- Load items to PgSTAC:
pypgstac load items ~/Documents/stac-strava/strava_items.json --dsn postgresql://username:password@localhost:5439/postgis --method upsert
Feel free to contribute to this project by opening issues or submitting pull requests.
This project is licensed under the MIT License.