This is a static archive of our old OSM Help Site. Please post any new questions and answers at community.openstreetmap.org.

How can I count numbers of natural=waters filtered by a country?

0

I'm interested to find out how many waterbodies there are in each countries. I have checked out http://taginfo.openstreetmap.org/tags/natural=water but can't figure out how to filter this stats by country. How can this be done?

asked 26 Oct '16, 12:40

Fishbrain's gravatar image

Fishbrain
36336
accept rate: 0%


2 Answers:

2

You cannot do that kind of analyses with taginfo. Some countries have there own local taginfo server (e.g. UK and Italy), in which case you can see it on that server for that country.

A solution would be to download the OSM data and use a program such as QGIS to split the waterbodies per country and count them. QGIS has a possibility to invoke an Overpass Query to obtain only waterbodies. You need to download the country boundaries as well.

answered 26 Oct '16, 14:45

escada's gravatar image

escada
19.0k16166302
accept rate: 21%

1

You can download the extract for the country of your choice and write a small C++ program which uses the Osmium library. I suggest to modify the osmium_road_length example program (currently it calculates the length of a road and adds the value to a variable).

The necessary modifications:

  • RoadLengthHandler::length should be int and renamed to waterbodys_count
  • You should query the natural instead of the highway tag at line 57
  • "if (highway)" (line 58) should be changed to "if (highway && !strcmp(highway, "water"))"
  • Replace "length += osmium::geom::haversine::distance(way.nodes());" by "++waterbodys_count;"
  • change the final output at line 90 (If you understand the points above, this will be easy)

answered 29 Oct '16, 14:03

Nakaner's gravatar image

Nakaner
610813
accept rate: 16%