OSMBorder extracts the admin boundary data from an OSM planet file and assembles all the pieces into linestrings for use in map renderers etc.
https://github.com/osmcode/libosmium
http://osmcode.org/libosmium
At least version 2.7.0 is needed.
http://www.zlib.net/
Debian/Ubuntu: zlib1g-dev
http://johnmacfarlane.net/pandoc/
Debian/Ubuntu: pandoc
(If pandoc is found by CMake, the manpages will automatically be built.)
You'll need the prerequisites including libosmium
installed.
OSMBorder uses CMake for building:
mkdir build
cd build
cmake ..
make
Call make doc
to build the Doxygen API documentation which will be available
in the doc/html
directory.
- Filter the planet with osmborder_filter
osmborder_filter -o filtered.osm.pbf planet-latest.osm.pbf
- Create linestrings with osmborder
osmborder -o osmborder_lines.csv filtered.osm.pbf
OSMBorder outputs a tab-delimited file that can be loaded directly into PostgreSQL. This requires a suitable table, which can be created, loaded, optimized, and indexed with
CREATE TABLE osmborder_lines (
osm_id bigint,
admin_level int,
dividing_line bool,
disputed bool,
maritime bool,
way Geometry(LineString, 3857));
\copy osmborder_lines FROM osmborder_lines.csv
CREATE INDEX osmborder_lines_way_idx ON osmborder_lines USING gist (way) WITH (fillfactor=100);
CLUSTER osmborder_lines USING osmborder_lines_way_idx;
CREATE INDEX osmborder_lines_way_low_idx ON osmborder_lines USING gist (way) WITH (fillfactor=100) WHERE admin_level <= 4;
The indexes are optional, but useful if rendering maps.
OSMBorder uses tags on the way and its parent relations. It does not consider geometry, relation roles, or non-way relation members.
The admin_level is the lowest admin_level
value of the parent relations. The way tags are not considered.
The presence of disputed=yes
, dispute=yes
, border_status=dispute
or disputed_by=*
on the ways is used to indicate part of a border is disputed. All the tags function the same, but disputed=yes
is my preference. Relation tags are not considered.
maritime=yes
, natural=coastline
or boundary_type=maritime
indicates a maritime border for the purposes of rendering. Relations are not considered, nor intersection with water areas.
-v, --verbose
Gives you detailed information on what osmborder is doing, including timing.
Run osmborder --help
to see all options.
OSMBorder is available under the GNU GPL version 3 or later.
Paul Norman ([email protected])
Based on OSMCoastline by Jochen Topf ([email protected])