Skip to content

initial draft for water layer#38

Draft
ratmice wants to merge 11 commits into
osmus:mainfrom
ratmice:water_layer
Draft

initial draft for water layer#38
ratmice wants to merge 11 commits into
osmus:mainfrom
ratmice:water_layer

Conversation

@ratmice

@ratmice ratmice commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Here is an initial draft for water layer (#35), this is going to conflict with PR #36 I'm happy to fix my PR up after that one is finalized, this one is probably not ready anyways.

I'm pretty new to OSM, and duckdb both, I just tried to base it off the existing scripts, changing the tags I could think of.

My initial thoughts were to not include POI like boat ramps from the leisure which would be contained in the POI layer in #36 but I figure if someone is using both the water layer and the POI layer they can just ignore the duplicate data in the water layer pretty easily?

For now I figure I'll just do anything remotely related to water, and we can decide at a later date what to include once we have a fairly complete set of tags.

Tagging notes:

  • Bridges over water vs bridges over land, I didn't see a way to differentiate them via tags, used a ST_Intersects query
  • emergency:assembly_point is sometimes missing assembly_point:tsunami (I assume we want to add the tag rather than include assembly_points that aren't water based?)
  • This is bringing in tags like ford=no under the assumption if it is covered in water you it is unsafe to ford.
    Are there any tags where we want to exclude values of no like where tags['foo'] IS NOT NULL and tags['foo'] != 'no'?
  • I'm not sure if we really want all the amenity=drinking_water, showers, foot_washes, sports, and swimming_pools, water_parks?

I have yet to really use this in anger yet

@ratmice ratmice force-pushed the water_layer branch 3 times, most recently from 4053f71 to c03a8ed Compare June 20, 2026 02:24
Currently this just tests that particular columns aren't empty
and that particular prefix_maps aren't empty.

This is fairly reliant on the imported region having tagged elements
for every tag being tested.
@ratmice

ratmice commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

Edit: The problem discussed here should be fixed in 9c4db48 and f1094b5 however the bridge query still slows down the import process quite a bit, so it probably needs to be discussed.

Hmm, I was looking into the `whitewater:* prefix_map, and looking for a good geofabrik region to test with.
Of the first two I tried (austria, and finland) both about the same size .osm.pbf files, the finland processing is taking oodles of both time and memory

Been running for over an hour compared to a minute or two for all other regions I've tested with.
Edit: Just changing the bridge query to include all bridges cut it down to 1.5 minutes for Finland so that has to be the problem.

I would suspect this might be the bridge query (without any actual evidence to suggest it). But it is taking vastly more resources than even larger regions like the UK and California. I suspect I'll need to get to the bottom of what's causing this for this to be viable.

ratmice added 2 commits June 21, 2026 16:01
The bridge query was resource heavy on areas with lots of water
like alaska, and finland.

This pulls them into a temporary table first before doing the join.
When doing this I ran into an issue with multi-threaded query planning.

for instance
```
CREATE OR REPLACE TEMP TABLE water_bridges AS
SELECT b.type, b.id, b.tags, b.geometry
FROM bridges_unfiltered b
JOIN water_features w
  ON b.geometry && w.geometry
  WHERE ST_Intersects(b.geometry, w.geometry);

...

    UNION ALL
        SELECT DISTINCT type, id, tags, geometry FROM water_bridges
```

Works while

```
CREATE OR REPLACE TEMP TABLE water_bridges AS
SELECT DISTINCT b.type, b.id, b.tags, b.geometry
```

segfaults with a floating point exception unless
`PRAGMA threads=1`
The previous commit helped, but we can probably reduce the number
of IO passes over {{INPUT}} to 2, which seems to help a bit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant