changed 4 years ago
Linked with GitHub

View OSM changes in time

Geofrabrik data

First let's get historical OSM data these can be downloaded from Geofabrik latest and full history select the country and download internal.osh.pbf - OSM login is required to download.

Then grab latest.osm.pbf which is up-to-date file with no history.

Osmium

Download Osmium

Prepare data for certain date as baseline e.g. Jan 1st 2019

osmium time-filter ./czech-republic-internal.osh.pbf 2019-01-01T00:00:00Z -o 2019_CZ_full.pbf

cut the area from whole country to bounding box of interest

osmium extract -b 16.842041,49.0288644,17.0145607,49.1162425 ./2019_CZ_full.pbf -o zdanice_2019.pbf

and optionally convert it to osm xml file (needed for JOSM; not needed for Maperitive)

osmium cat zdanice_2019.pbf -o zdanice_2019.osm

Prepare latest data by cutting the same area

osmium extract -b 16.842041,49.0288644,17.0145607,49.1162425 ./czech-republic-latest.osm.pbf -o zdanice_latest.pbf

remove everything apart from paths and tracks

osmium tags-filter zdanice_latest.pbf w/highway=track,path -o zdanice_latest_cesty.pbf

and optionally convert to osm xml

osmium cat zdanice_latest_cesty.pbf -o zdanice_latest_cesty.osm

Compare

There are varios scripts and tools which can be used like basic perl script Osmdiff or big GIS package QGIS (which I never had luck with to understand it)

I decided to go first with JOSM which's my tool-to-go for map edits. It can open osm xml, but was quite sluggish with the files (filtering historical extract for only some entities would help).

Next I tried Maperitive (sorry, Win only) which I found better option in this case. Simply turning on/off layer with added path/tracks in current data file did the trick (had to edit a bit rules of Maperitive renderer, but that's different story).

2019 -

July 2020 -

Timelapse

To create timelapse more historical snapshots are needed. To avoid processing big file many times I though sorting it would help (note this is pretty RAM intensive operation, for Czech republic - relatively small country - it didn't work on less than 16GB RAM and ate 8GB swap as well).

osmium sort --verbose czech-republic-internal.osh.pbf -o czech-republic-sorted.pbf

however it didn't

osmium extract -b 16.842041,49.0288644,17.0145607,49.1162425 ./czech-republic-sorted.pbf -o zdanice_with_history.pbf
[======================================================================] 100% 
Node ID twice in input. Maybe you are using a history or change file?
This command expects the input file to be ordered: First nodes in order of ID,
then ways in order of ID, then relations in order of ID.

so I wrote perl script to create ways from historical country dump

#! /usr/bin/perl -W
use strict;
use warnings;

sub cut_data() {
	my ($date) = @_;
	system('osmium time-filter czech-republic-internal.osh.pbf ' . $date . '-01T00:00:00Z -o ' . $date . '_CZ_full.pbf');
	system('osmium extract -b 16.842041,49.0288644,17.0145607,49.1162425 ' . $date . '_CZ_full.pbf -o zdanice_' . $date . '.pbf');
	system('rm ' . $date . '_CZ_full.pbf');
	system('osmium tags-filter zdanice_' . $date . '.pbf w/highway=track,path -o zdanice_cesty_' . $date . '.pbf');
	system('rm zdanice_' . $date . '.pbf');
}

&cut_data('2019-03');
&cut_data('2019-05');
&cut_data('2019-07');
&cut_data('2019-09');
&cut_data('2019-11');
&cut_data('2020-01');
&cut_data('2020-03');
&cut_data('2020-05');
&cut_data('2020-07');

this produced point-at-time files with paths and tracks only

ls | grep pbf
zdanice_cesty_2019-03.pbf
zdanice_cesty_2019-05.pbf
zdanice_cesty_2019-07.pbf
zdanice_cesty_2019-09.pbf
zdanice_cesty_2019-11.pbf
zdanice_cesty_2020-01.pbf
zdanice_cesty_2020-03.pbf
zdanice_cesty_2020-05.pbf
zdanice_cesty_2020-07.pbf

In Maperitive make png for each of them (we already have latest and Jan 2019 from earlier on) by simply turning on/off layers and export (CTRL+E).

ls | grep png
2019_01.png
2019_03.png
2019_05.png
2019_07.png
2019_09.png
2019_11.png
2020_01.png
2020_03.png
2020_05.png
2020_07.png
2020_latest.png

To make a movie I used imagemagick's utility convert

convert -delay 100 -quality 100 *.png timelapse.mp4

which produced video below, each frame is one second.

https://tube.tchncs.de/videos/watch/b32b0f29-aadc-48d3-8e65-ee4d5b2a8226

Select a repo