Back in 2013 I had an opportunity to drive across the US from Chicago to Los Angeles in good company. I was expecting a once in a lifetime trip and I wanted to document it properly. Since I knew I'd be mostly in charge of driving I wouldn't be able to watch the scenery change slowly and take pictures. Little did I know we'd go back the following year to drive from Denver to Seattle... Dashcams weren't as common back then and they lacked (and still do) some of the functionality that I ended up wanting so I ended up rolling my own solution as I wanted to have both the images and some maps etc. to show where the image was taken. I figured I could use a Gopro cam and mount it on the dashboard and set it up to take photos every 30 seconds while simultaneously logging our route with a GPS. The purpose of this page is to give readers an idea on how I pieced together the GPS data and photos, and some tips and caveats in case someone is planning to do the same.
Dashcam image amended with GPS data, and generated maps.
You need to have some programming skills to pull this off. I'm not going to release all of my scripts. First of all, they probably wouldn't work as your gps data is likely in a different format. Also, they are a complete mess and very inefficient, and I don't have the slightest ambition to repond to the "Sir, script xxx doesn't work please help" emails. I'm only releasing the ones that will pretty much work for everyone. If your programming skills are like mine i.e. search stackoverflow.com for code snippets and modify them to suit your needs you'll do just fine but you should note that this will take days (or more likely weeks). If you can't program, I'd say it is not worth trying to use GPS data but to create a movie of the captured photos instead and forget GPS data (but save it - you never know if you'll need it).
You will need need the following equipment:
Essentially there are five things you must remember:
That's it really. I'd recommend you to also back up both GPS and dashcam data, and ensure you won't run out of storage space. I'd also recommend you to capture images at 10 second intervals rather than once a minute. Memory cards are cheap so no need to skimp out on them. You should also choose a dashcam that produces at least 5 megapixel images if you're aiming for 4k resolution with the end product.
Now that you have returned back home with a few memory cards full of data it is time to process the files. This stage is relatively easy and takes a day or so depending on programming skills.
So the first stage was easy. Now you'll have to start processing GPS data into map tiles and transform coordinates into addresses. I recommend you to set up your own tile server. It will take some time and effort but it beats scraping thousands of tiles. There are good instructions for setting up a tile server at Switch2OSM webpage. You'll also need to grab tile packages. Geofabrik has sub-region extracts. Don't even think about grabbing the planet set and set up a tile server that covers entire enitre planet unless you really know what you're getting yourself into and have enough storage space and memory. I ended up having four separate tile servers (including four separate instances of postgres) each of them serving tiles from separate data sets. If you have enough storage space and memory, I highly recommend using as subset as possible in order to avoid having several instances.
I suppose you could set up Nominatim to reverse coordinates into addresses, but I never got it working as I always ran out of either memory or storage space. I opted to use Mapquest's API. That took a week or so as I did 4 requests per minute out of courtesy, and I wasn't in a hurry.
On Ubuntu 20.04 with postgres 12 I used the following commands to create tile servers. Just install any dependencies you're complained about. If you create more than one tile server remember to change DBNAME and PORT (default=5433) to create separate carto stylesheets for each tile server (i.e. change PORT and DBNAME). You'll either have to run these as root or postgres - depends on your configs.
cd /var/lib/postgresql/12 mkdir DBNAME sudo chown postgres:postgres DBNAME -R
At least the first to rows must be run as user postgres. Ensure postgres and www-data can write to datadir.
/usr/lib/postgresql/12/bin/initdb -D /var/lib/postgresql/DBNAME pg_createcluster --datadir=/XXX/xxxx/DBNAME/ 12 DBNAME service postgresql restart pg_ctlcluster 12 DBNAME start
Check out help section of osm2pgsql especially re: -C parameter and change osm.pbf file name. Depending on your osm.pbf file, computer specs and the resources you allocate this will take anything from minutes to days. My 5 year old Dell laptop populates e.g. the US West database in approximately 90 minutes.
createdb DBNAME -p PORT psql -p PORT -d DBNAME -c 'CREATE EXTENSION postgis; CREATE EXTENSION hstore;' osm2pgsql -c -s -C 2500 -P PORT -d DBNAME /pathto/us-west-latest.osm.pbf
If you can't generate tiles run the following as postgres user in postgres databases.
GRANT ALL on geometry_columns TO "www-data"; GRANT ALL ON SCHEMA PUBLIC TO "www-data"; GRANT ALL on spatial_ref_sys TO "www-data"; GRANT ALL on planet_osm_line TO "www-data"; GRANT ALL on planet_osm_nodes TO "www-data"; GRANT ALL on planet_osm_point TO "www-data"; GRANT ALL on planet_osm_rels TO "www-data"; GRANT ALL on planet_osm_roads TO "www-data"; GRANT ALL on planet_osm_ways TO "www-data"; GRANT ALL on planet_osm_polygon TO "www-data";
Now that you have married your images with location data, and you've generated map tiles and reversed coordinates into addresses it is time to put it all together. I used mainly Imagemagick.
mencoder "mf://*.jpg" -nosound -of lavf -lavfopts format=mp4 -ovc x264 -x264encopts crf=18 -o movie.mp4 -mf type=jpg:fps=3
Last updated on 4 December 2020. No javascript, no tracking, no ads, no cookies. The way it is supposed to be.