Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/christippett/bigquery-geo-router
Calculate routes from long/lat coordinates in BigQuery using OpenStreetMap/OSRM
https://github.com/christippett/bigquery-geo-router
bigquery geospatial google openstreetmap osrm
Last synced: about 1 month ago
JSON representation
Calculate routes from long/lat coordinates in BigQuery using OpenStreetMap/OSRM
- Host: GitHub
- URL: https://github.com/christippett/bigquery-geo-router
- Owner: christippett
- License: mit
- Created: 2020-04-25T13:31:08.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-09-12T20:03:21.000Z (over 4 years ago)
- Last Synced: 2024-01-29T09:38:11.265Z (11 months ago)
- Topics: bigquery, geospatial, google, openstreetmap, osrm
- Language: TypeScript
- Size: 172 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BigQuery Geo Router
Converts a series of long/lat coordinates in BigQuery into routes generated using [OpenStreetMap data](https://www.openstreetmap.org/) and the [Open Source Routing Machine](http://project-osrm.org/).
The resulting data can be loaded back into BigQuery for further analysis - each route is typed appropriately to be used with BigQuery's [geospatial querying functionality](https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions).
## Usage
### Setup
The first step is to download and prepare the OpenStreetMap data for the region you're interested in calculating routes for.
[Geofabrik](https://download.geofabrik.de/) has a number of regional OpenStreetMap extracts that can be used as our starting point. The included Cloud Build config, `cloudbuild-setup.yaml`, takes care of many the of steps you need to get everything set up.
The two main parameters needed for the Cloud Build job are `_OSM_NAME` and `_DATA_BUCKET`.
- `_OSM_NAME`: this is the name, including any prefixes, for the OpenStreetMap data file available from Geofabrik (the Cloud Build job is configured to download extracts from this location). The example below is referencing the data for Illinois available [here](https://download.geofabrik.de/north-america/us/illinois.html) (note the URL path and its correlation to `_OSM_NAME`).
- `_DATA_BUCKET`: the name of the Google Cloud Storage bucket where the resulting files will be saved and referenced when calculating routes.```bash
gcloud builds submit \
--config cloudbuild-setup.yaml \
--substitutions=_OSM_NAME=north-america/us/illinois \
--substitutions=_DATA_BUCKET=gs://my-bucket-for-storing-routing-data
```### Generating Routes
Once the above step is complete, routes can be calculated by running (another) Cloud Build job. The job builds a Docker container containing a Node.js application that queries BigQuery and runs the routing calculation process. The resulting routes are output to a local JSON file that can subsequently be loaded back into BigQuery.
The input to the route calculator can either be a reference to a table in BigQuery (in the format `dataset.table`) or the path to a SQL file.
```bash
gcloud builds submit \
--config cloudbuild.yaml \
--substitutions=_OSM_NAME=north-america/us/illinois \
--substitutions=_DATA_BUCKET=gs://my-bucket-for-storing-routing-data
--substitutions=_DESTINATION_DATASET=trip_routes \
--substitutions=_INPUT_TABLE=trip_routes.trips
```## Visualising Routes
TBC
## Configuring OSRM
TBC