Hello, I have a big osm file and I have the ids of 430 relations (in a text file) and I want to extract the data related to them from the osm file (I understand the hierarchy ( x relation -> x.y0, x.y1...x.yn ways -> x.y[0...n].z[0...t] nodes )) to make my osm file smaller. But I don't know where to begin ? I think that I need to import the osm file into postgis and then run queries ? I thought also to use the openstreetmap API and queries for each relations their ways and ... queries for each ways their nodes ... Then merge all of it. But it isn't very powerful... Is there a better way to create my custom osm file ? Thanks for your help, best regards, asked 06 Mar '16, 15:40 syskaw |
You can use the osmium command line tool for this. The "add-refs" subcommand does what you need. You'll have to use the master version from github, the released versions don't have this command yet. Use it like this:
with relation-ids file containing one relation id per line preceded by the letter 'r'. answered 07 Mar '16, 21:11 Jochen Topf it works like a charm, thanks you :)
(08 Mar '16, 00:49)
syskaw
|
You should not use the OpenStreetMap api to fetch the relations. It may work to fetch them from Overpass API. It's possible to query by object id, so you could use something like
(look at the Overpass QL documentation for more information, especially the sections on "Union" and "By Element Id") I'm not sure that it would be acceptable to query so many relations, if they are large, the query would have a large result. Another approach that doesn't need a database is to use whatever programming tools you are familiar with to read through the large file 3 times. The first time, when you encounter a desired relation, extract it and also make a list of the ways that are members of the relation. The second time, extract the list of ways and make a list of the nodes that are members. The third time, extract the list of nodes. answered 06 Mar '16, 16:28 maxerickson |