[OSM-dev] How to find the way with the most relation memberships

Simon Poole simon at poole.ch
Mon Aug 27 09:41:49 UTC 2018


Come on, you'reĀ  leaving us out on a limb. Now we want to know the world
leader in relation membership :-).


Am 27.08.2018 um 01:00 schrieb Frederik Ramm:
> Hi,
>
> in the course of a discussion over on talk-gb, I wanted to find out
> which ways have the highest number of relation memberships. In case
> someone is interested, here's how to do it with Osmium and Perl.
>
> 1. create this Perl script which reads "opl" ascii format
>
> #!/usr/bin/perl
>
> while(<>)
> {
>     next unless /boundary/;
>     s/.* M//g;
>     foreach (split(/,/))
>     {
>         my ($a,$b)=split(/@/);
>         $mem{$a}++;
>     }
> }
>
> $i=0;
> foreach (sort { $mem{$b}<=>$mem{$a} } keys(%mem))
> {
>     printf "%d %s\n", $mem{$_}, $_;
>     last if ($i++>100);
> }
>
> 2. feed an .osm.pbf file into it:
>
> osmium cat some-file.osm.pbf -trelation -fopl | perl myscript.pl
>
> I ran this for England and found a small number of ways that were
> actually in over 100 different (bus route) relations ;)
>
> If you like Python, you could of course do the whole thing in one go
> using the PyOsmium library
>
> Bye
> Frederik
>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20180827/62d2908d/attachment.sig>


More information about the dev mailing list