Pulling Polygonal Water Features

I’m using OSMOSIS to pull water polygons from an “.osm” file, which I extracted from PlanetOSM data… I’m using the tag filter “natural=water”, which I assumed would pull all water features, but it doesn’t. If I query one of the missing features which failed from the OSMOSIS extract from openstreetmap.org’s web map interface it says:
name Laguna Madre
natural water
type multipolygon
water lagoon

Is there some other tag filter I should be using?

1 Like

It’s possible Osmosis may have omitted Laguna Madre because of an invalid multipolygon geometry. relation/5121863 has a recent edit that fixed an inner island (Changeset # 146388868).

I tried using OSMIUM yesterday using the exact tag filter(copy/paste) and same OSM/PBF file as input and it pulled out all the water features correctly. Not sure why OSMOSIS doesn’t work. Seems to work correctly on other features I’m pulling ie. highways. Anywho, I’m switching all my feature type pulls to OSMIUM. Eventually we’ll write our own parser in C++/Java so we have better control over AND/OR operations when separating the data layers.

2 Likes

This may also be a good use case for the GeoDesk toolkit. You can extract OSM features using a query language similar to Overpass, analyze and process them, and then export in a variety of formats. Works in Java, Python, or via a command-line utility (100% free & open-source).

For example:

from geodesk import *

world = Features('world.gol')
water_areas = world("a[natural=water]")
for water in water_areas:
    print(water.name)    # The feature's name
    print(water.shape)   # Its geometry
    print(water.area)    # Its size in square meters

Or, to simply export all water features as GeoJSON:

gol query world a[natural=water] -f=geojson > water.geojson

(You can build world.gol from the .osm.pbf planet file using the GOL Tool; this takes less than an hour on any reasonably modern machine)