Hosting Pelias and Valhalla
Whether it’s about optimizing delivery routes or analyzing regional market trends, location data plays a pivotal role. However, when it comes to handling geospatial data, many businesses immediately think of popular services like Google Maps or Bing Maps. While these services are powerful, they might not always be the best choice, especially for businesses requiring offline solutions or those conscious of escalating costs.
The Cost Factor with Popular Mapping APIs
Using APIs from Google Maps or Bing Maps for business analysis can get prohibitively expensive, especially as your data needs scale. These services are typically priced based on the number of requests or transactions, which can quickly add up for intensive geospatial analysis tasks.
The Power of Offline Solutions: Pelias and Valhalla
Enter Pelias and Valhalla – open-source projects that excel in geocoding and route optimization, respectively. These tools offer a more cost-effective approach, particularly for businesses needing extensive data analysis while keeping operational costs in check.
Pelias is an open-source geocoding engine, allowing for converting addresses into GPS coordinates and vice versa. It stands out for its flexibility in ingesting data from various sources, including OpenStreetMap, and its ability to run entirely offline.
Valhalla, on the other hand, is a powerful routing engine. It offers turn-by-turn navigation, isochrone analysis, and matrix routing, among other features.
Implementing Pelias with Docker
There is a neat guide for setting up Pelias with Docker: git repo
Follow thru the steps and you should be able to get Pelias up and running. However it is using outdata openstreetnames, there are some issues with the data.
Moreover I got into an issue with Valhalla tiles not being present.
pelias prepare all
pelias import all
I would recommend building tiles with this docker image
docker run \
--rm -it \
-v '/home/azureuser/codebase/pelias-docker/projects/north-america/data/openstreetmap:/data/valhalla' \
-v '/home/azureuser/codebase/pelias-docker/projects/north-america/data/openstreetmap:/data/polylines' \
pelias/valhalla_baseimage \
/bin/bash -c './scripts/export_edges.sh'
Only building Pelias offers the geocoding aspect, but if you want drive time and routes you need to build Valhalla.
You can test out the geocoding with pelias and your personal docker image to Mapzen - (still Pelias)
Implementing Valhalla with Docker
To integrate Valhalla into your system, Docker offers a straightforward approach. Here’s a snippet of a docker-compose.yml file to set up Valhalla:
version: '3.0'
services:
valhalla:
image: gisops/valhalla:latest
ports:
- "8002:8002"
volumes:
- ./custom_files/:/custom_files
environment:
- use_tiles_ignore_pbf=True
- force_rebuild=False
- force_rebuild_elevation=False
- build_elevation=True
- build_admins=True
- build_time_zones=True
This configuration sets up Valhalla with Docker, specifying essential environment variables and mapping ports for accessibility. The custom_files volume is particularly noteworthy, as it allows you to use your own data tiles for personalized routing. If you internal data for driving certain heavier vehicles you can customize the routing to take that into account.