[OSM-talk] Computing the 12-mile line

Roland Olbricht roland.olbricht at gmx.de
Sat Feb 21 23:36:24 GMT 2009

> I just tagged up the one I found in the database, I attempted to use
> GIS software to create a section where it misses a scottish island,
> but failed after 2-3 days of playing, I can't recall who put the data
> in originally.
> I'd be interested in seeing any code put into svn for others to use.
> On 20/02/2009, Adrian Frith <adrian at frith.co.za> wrote:
> > For those of you who have been adding the 12-mile "territorial waters"
> > line: did you calculate that data by offsetting the coastline/baseline?
> > And if so, how did you do it? I mean: what software did you use, and
> > how?

I've generated the source code with a tool handwritten in C++. You can find 
the source code in the file "sweep-brim.c" on the site

The code itself is a mess and far from being user friendly, I wrote it merely 
to use it by myself. I stopped to use it because it fails on quite a lot of 
coastline errors. But I would be glad to reanimate it if you would like to 
use it or understand it. If you would like to get a particular piece of 
coastline, just ask for it.

The basic idea of how to use it:

Feed it a file of coastlines and a file with the resprective nodes. You can 
produce these files with osmosis by filtering for ways tagged 
as "natural" "coastline" and the nodes they point at. Or you can use the 
script "coastline-extractor" from the same site with a .bz2-file as the only 
argument, then use "filter-nodes-bbox" (compiled from "filter-nodes-bbox.c") 
with a bounding box for the four arguments. Finally you can feed the two 
files as arguments to "sweep-brim". The compiling flags 
for "filter-nodes-bbox.c" and "sweep-brim.c" are given in the 
file "coastline-extractor". Unfortenatley, you then have to manually dig the 
right component from all the produced data - the tool produces also junk data 
for the onshore side of a segment and it is pretty hard to find and truncate 
the correct brim automatically. I've done it by hand.

Be aware that the whole process is quite slow. The extraction of the coastline 
can take some hours. The calculation of the brim should take some minutes. 
Then the upload might take quite a lot of time - the coastlines of France and 
Spain were a weekend and the United Kingdom another weekend.

The basic idea of how it works:

Image the planet covered with equidistant scanlines along the latitudes (the 
distance between to scanlines is currently 0.001 degrees of latitude). Now 
you add for every segment of every way from the coastline all the intervals 
of points on each scanline that are less than 12 nm from any point of that 
way (simplified: take into account only the endpoints of the segment and the 
intersections with the scanlines - the inaccuracies won't matter compared to 
the scanline gaps or the projection correction). After the tool has taken the 
union of all those intervals, it spans a way from interval border to interval 

I will give more detailed explanations or run the tool on a particular region 
if you would like to. But I'm abroad for some days from tomorrow morning. So 
please ask, I'll try to answer on thursday evening.

There is also a tool mentioned on 


More information about the talk mailing list