Git Product home page Git Product logo

osmborder's Introduction

OSMBorder

OSMBorder extracts the admin boundary data from an OSM planet file and assembles all the pieces into linestrings for use in map renderers etc.

Prerequisites

Libosmium

https://github.com/osmcode/libosmium
http://osmcode.org/libosmium
At least version 2.7.0 is needed.

zlib (for PBF support)

http://www.zlib.net/
Debian/Ubuntu: zlib1g-dev

Pandoc (optional, to build documentation)

http://johnmacfarlane.net/pandoc/
Debian/Ubuntu: pandoc
(If pandoc is found by CMake, the manpages will automatically be built.)

Building

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.

Testing

Running

  1. Filter the planet with osmborder_filter
osmborder_filter -o filtered.osm.pbf planet-latest.osm.pbf
  1. Create linestrings with osmborder
osmborder -o osmborder_lines.csv filtered.osm.pbf

Output

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.

Tags used

OSMBorder uses tags on the way and its parent relations. It does not consider geometry, relation roles, or non-way relation members.

admin_level

The admin_level is the lowest admin_level value of the parent relations. The way tags are not considered.

disputed

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

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.

Options

-v, --verbose

Gives you detailed information on what osmborder is doing, including timing.

Run osmborder --help to see all options.

License

OSMBorder is available under the GNU GPL version 3 or later.

Authors

Paul Norman ([email protected])
Based on OSMCoastline by Jochen Topf ([email protected])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.