How can I tell what sea or ocean my user is in?

Hello, my first ever post here.
In my application, I need to be able to work out what sea or ocean my user is in. My user is basically a point at a given long/lat.
I can work out which country my user is in because I have all the ISO3166 boundary relations and I can detect if I am inside a country’s polygon.
But there doesn’t seem to be consistent and comprehensive sea/ocean area relations.
There are about 63 relations where place=sea but this isn’t comprehensive. The 5 oceans seem to be defined by just 5 nodes.
There are lots of ways where natural=coastline but although land is defined as being on the left and water on the right, there is no information in the tags as to what the water is (or the land come to that).
How can I programmatically determine if, when my user moves themselves to say -50 lat and -10 long they are in the North Atlantic Ocean?
In case it is relevant to the solution, this application is for blind users navigating a map of the world. So just looking at a render of the map isn’t sufficient.
Many thanks for any guidance.

1 Like

Fast and easy solution: The opencage geocoder could help with your needs, e.g. test here: OpenCage Geocoding API Demo with search coordinates -1.0,0.3 as an example.

Otherwise you may try to work with the gazetteer data of

Edit: Who’s on first also has some ocean data included, check here: Who's On First Data · GitHub

Try the “marine labels” data set from Natural Earth » Blog Archive » Physical Labels - Free vector and raster map data at 1:10m, 1:50m, and 1:110m scales

OpenStreetMap is unsuitable for your use case since if we were to construct polygons for the oceans, they would be immensely complex and nearly impossible to edit due to OSM always working at high resolution - if someone were to create an “Atlantic Ocean” polygon in OSM I would immediately delete it because it would severly impede the editing of any coastline involved!

Hi, thanks for the reply.
I’d ideally like to use OSM data due to it being open, free and in easy data formats.
Beginning to think that it isn’t possible.
Are there any OSM based approaches for working out which body of ocean/sea a point is in?
Kind regards.

In OSM, oceans are merely constructed through coastlines, see e.g. the water polygons at Water polygons but while those could be used to define if you are in an ocean, it won’t help in getting the oceans name.

So in OSM oceans are only set as a mere node, e.g. this one: Node: ‪South Atlantic Ocean‬ (‪305640288‬) | OpenStreetMap but this may help in getting a label on a map but not for reverse geocoding.

Thanks. That does look like the polygons I need although I’ve no idea how to read a shapefile into my application. But as you say, won’t help me know which body of water I am in.
I’m a bit stuck at the moment. Whatever I do is going to have to be a real kludge. Maybe wikidata can help by telling me names of water bordering a country.
Many thanks for your help and confirming the situation.

Where’s the limit and would there be a way to create a type of super area like there are super routes? 2 Cases. The SS16 in Italy as route has 4000 members. Modify any way, cut up a road section or merge to accommodate a bus route change, a turn restriction, a new roundabout and the whole of Italy lights up. There 's a Gulf of Genova, 7K members. Some 5 node sections are involved is 10-12 relations. To verify the outline is closed one has to spend half an hour downloading coastal sections bit by bit as JOSM will else complain too much data is tried to be fetched in one go… Oh, and while checking and searching for the link someone did delete the monster and replaced it with a node in the centre of the Gulf. \o/

Replying to a couple of comments here.
I haven’t found a screen reader friendly way to convert shapefiles to a different format at the moment though command line tools is a good idea. First trying help from a sighted friend :slight_smile:
And this question of terratorial waters as part of the boundary relation. This isn’t a problem until I zoom in and start taking steps of less than about 10km around the map.
Have a kind of idea of taking admin_level 6 relations, as I know the country these are in, and extracting the ways that aren’t shared between relations as a coastal way isn’t a border between two admin_level relations.
But yes, currently stuck on this also. Currently filed under “Deal with this later as too tricky for now”.