OpenStreetMap 标志 OpenStreetMap

Waterway relations

The waterway=river tag is used in OSM on ways that make up a river. Like many things in OSM, an actual river will almost certainly be split up into many individual ways. Luckily there is a waterway relation. You can create one relation for each actual river, and then add all the ways that make up the river into that relation. Data consumers can then easily work with one object for a river and reason about it. (e.g. How long is it? What countries is this river in? What other rivers flow into it?)

Using Overpass to find missing waterway relations

Adding rivers to the relation is easy enough. But how do you know how to find them? Overpass Turbo can be used for that.

This overpass query will show you all the rivers in a bbox which are candidates for a waterway relation:

[out:json][timeout:250];
(
  // all ways that are tagged river, and have a name
  way["waterway"~"(river|stream)"]["name"~"."]({{bbox}});
  -
  // minus all the ways that are in a relation
  ( relation["type"="waterway"]({{bbox}}) ; > );
);
// print results
out body;
>;
out skel qt; 

It find all ways with the waterway=river or waterway=stream tag, that also have a name tag, and it excludes all ways that are already in a type=waterway relation.

Loading into JOSM

When you have run that query in Overpass Turbo, you can export the result to JOSM using the remote control feature of JOSM.

However JOSM has a very useful “Download from Overpass API” feature for loading data direct into JOSM, if you want to avoid your browser having to load and display a massive amount of data. However you must use a slightly different overpass format. Instead of {{bbox}} use bbox. This is the query you need for JOSM:

(
  // all ways that are tagged river, and have a name
  way["waterway"~"river|stream"]["name"~"."](bbox);
  -
  // minus all the ways that are in a relation
  ( relation["type"="waterway"](bbox) ; > );
);
// print results
out meta;
>;
out meta;

Examples

Some examples of waterway relations:

电子邮件图标 Bluesky图标 Facebook图标 LinkedIn图标 Mastodon图标 Telegram图标 X图标

讨论

Taz602016年04月16日 08:25 的评论

That’s weak like yourself

Marcos Dione2016年04月16日 14:36 的评论

What about just extending a previously existing relation? Should we just remove the filter in the second line? Another thing very common in Europe is very long rivers that go through several countries, hence having different names. The most clear example, the Danube, has all these names:

  • Danube
  • Donau
  • Donau - Dunaj
  • Duna
  • Duna / Dunaj
  • Dunaj
  • Dunărea
  • Dunărea - Дунав
  • Dunav
  • Дунав
  • Дунай

Marcos Dione2016年04月16日 14:56 的评论

However JOSM has a very useful “Download from Overpass API” feature

Also, what’s the name of the plugin who provides this?

amapanda ᚛ᚐᚋᚐᚅᚇᚐ᚜ 🏳️‍⚧️2016年04月18日 08:44 的评论

However JOSM has a very useful “Download from Overpass API” feature

Also, what’s the name of the plugin who provides this?

That feature should be in JOSM without needing any plugins I think? Maybe you need to turn on “Expert mode” in the settings to see it?

amapanda ᚛ᚐᚋᚐᚅᚇᚐ᚜ 🏳️‍⚧️2016年04月18日 08:59 的评论

What about just extending a previously existing relation? Should we just remove the filter in the second line?

I’m not sure what you mean. This overpass query is for finding new, un-relation’ed, rivers. If there’s an existing waterway relation which is missing some parts, then yes, you should add those ways to the correct relation.

Another thing very common in Europe is very long rivers that go through several countries, hence having different names. The most clear example, the Danube, has all these names:

The Danube is already mapped as a relation in OSM: Relation 89652. It has all the appropriate name:XX multilingual tags, however the name tag is set to “Donau”. I’m unsure if that’s correct, but I’m unsure what a correct name tag should be.

登录以留下评论