public
Last active

Openstreetmap changeset statistics of source tags.

  • Download Gist
id+source.pl
Perl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
# wget http://planet.openstreetmap.org/changesets-120229.osm.bz2
# tail -c 1000000 changesets-120229.osm.bz2 >tail.bz2
# bzip2recover tail.bz2
# bzcat rec000* |perl id+source.pl >all_sources.txt
 
$id=0;
$source=0;
while(<>){
if(/<changeset.* id="([^"]*)"/){
$id=$1;
$changesets++;
}
 
if(/tag k="source" v="([^"]*)/){
$source++;
print "$id: $1\n"
}
if ( $changesets % 10000 == 1)
{
print STDERR "$changesets/$source: ". $source/$changesets."\n";
}
}
 
print STDERR "DONE\n";
print STDERR "$changesets/$source: ". $source/$changesets."\n";
idsource.pl
Perl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
# Latest means "changesets-120229.osm.bz2"
# wget http://planet.openstreetmap.org/changesets-latest.osm.bz2
# tail -c 1000000 changesets-latest.osm.bz2 >tail.bz2
# bzip2recover tail.bz2
# bzcat rec000* |perl id+source.pl >all_sources.txt; rm rec000*
# bzcat changesets-latest.osm.bz2 |perl id+source.pl >all_sources_2.txt
$id=0;
$source=0;
while(<>){
if(/<changeset.* id="([^"]*).* num_changes="([^"]*)/){
$id=$1;
$num_changes=$2;
$total_changes+=$num_changes;
$changesets++;
}
 
if(/tag k="source" v="([^"]*)/){
$source++;
print "$id: $1: $num_changes\n";
$source_changes+=$num_changes;
}
if ( $changesets % 10000 == 1)
{
stats();
}
}
 
print STDERR "DONE\n";
stats;
 
sub stats{
print STDERR "Changets: $source/$changesets: ". $source/$changesets." Number of changes: $source_changes/$total_changes:". $source_changes/$total_changes . "\n";
 
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.