NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

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%


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.

permanent link

answered 26 Oct '16, 14:45

escada's gravatar image

escada
19.0k16166302
accept rate: 21%

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)
permanent link

answered 29 Oct '16, 14:03

Nakaner's gravatar image

Nakaner
610813
accept rate: 16%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×5

question asked: 26 Oct '16, 12:40

question was seen: 1,663 times

last updated: 29 Oct '16, 14:03

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum