OSMCoastline

From OpenStreetMap Wiki
Jump to navigation Jump to search
Osmcoastlines-lang-polygons.png

OSMCoastline is a program to extract coastline data from OSM and bring it into an easily usable format. OSMCoastline is Open Source, it is written in C++ using the Osmium framework. The source code is at https://github.com/osmcode/osmcoastline

What it does

OSMCoastline reads an OSM file and extracts all ways tagged with natural=coastline. It then assembles those lines into (large) multipolygons fixing smaller errors in the process. The data is written into a Spatialite database, which can be used as is or easily be converted to Shapefiles and other formats using (for instance) OGR.

You can use command line switches to decide which data you want:

  • Projection: Data can be written out in WGS84 (EPSG:4326) or web Mercator (EPSG:3857).
  • Coastlines can be written as lines and/or land polygons and/or water polygons.
  • Long lines and large polygons can either be written as they are or split into smaller segments/polygons. Usually you want the split data, otherwise you have to deal with continent-sized polygons.

OSMCoastline comes with a small SQL script to simplify the generated coastline polygons.

OSMCoastline also generates error information in the form of several tables in the output file. This information can be used to fix the coastline. It is also available in the coastline view of the OSM Inspector.

For more details check the README.md.

Why do we need it?

More or less everybody who creates maps from OpenStreetMap data needs coastlines (or land or water polygons). But coastlines are tricky to generate from OSM data and the other programs converting OSM data to something usable for map rendering (such as osm2pgsql) don't know how to do this. So in addition to your other software for rendering maps, you probably either need to use OSMCoastline or download data generated with it.

Comparison to coastcheck

OSMCoastline is actively maintained, has more features, is easier to use, better documented and much faster than the Coastline error checker ([1]) program that has been used for similar tasks. If you are using coastcheck, you should probably switch.

Downloads

Results of this program are available at osmdata.openstreetmap for download.