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])

osmborder's People

Contributors

frodrigo avatar lseelenbinder avatar maxsem avatar pnorman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

osmborder's Issues

GitHub releases with downloadable data

Paul, thanks for working on this! Great project. This ticket is an idea for improvement, which should be easy to do.

What about to start to make GitHub "release" for major versions this project?

Maybe the ready-to-use processed data (SHP/CSV/...) from the release could be attached to the release instead of placing it on your private "legolas" server?

See:
https://help.github.com/articles/distributing-large-binaries/
The limit is 2 GB per file, which should be fine for this project.

You get a reliable and fast download service for the produced data this way. We use it on OSMNames.org too.

Deal with partial diff's

If I understand it correctly, the tool currently cannot deal with partial diffs. This means that anytime a change involving borders is made, the entire table need to be recalculated. It would be nice (but likely far from trivial) to make the tool so that it can also consume partial (minutely?) diffs.

core dump using a pbf from osmconvert

osmborder_filter -v -o filtered.pbf data/hawaii.osm.pbf   
[ 0:00] Reading relations (1st pass through input file)...
[ 0:01] Preparing way ID list...
[ 0:01] Reading ways (2nd pass through input file)...
[1]    923404 segmentation fault (core dumped)  osmborder_filter -v -o filtered.pbf data/hawaii.osm.pbf

Extracted via:

osmconvert /opt/data/public_files/planet-v0.1.osm.pbf --complete-multipolygons --complete-boundaries --complete-ways --drop-author -B=hawaii.poly -o=hawaii.osm.pbf
#0  0x000071520d82ece5 in raise () from /usr/lib/libc.so.6
#1  0x000071520d818857 in abort () from /usr/lib/libc.so.6
#2  0x000071520dbb181d in __gnu_cxx::__verbose_terminate_handler () at /build/gcc/src/gcc/libstdc++-v3/libsupc++/vterminate.cc:95
#3  0x000071520dbbe2ea in __cxxabiv1::__terminate (handler=<optimized out>) at /build/gcc/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:48
#4  0x000071520dbbe357 in std::terminate () at /build/gcc/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:58
#5  0x000071520dbbe5be in __cxxabiv1::__cxa_throw (obj=<optimized out>, tinfo=0x5eb60f5c4fe0 <typeinfo for std::system_error@@GLIBCXX_3.4.11>, 
    dest=0x71520dbea940 <std::system_error::~system_error()>) at /build/gcc/src/gcc/libstdc++-v3/libsupc++/eh_throw.cc:95
#6  0x00005eb60f5aee17 in osmium::io::detail::open_for_writing (allow_overwrite=<optimized out>, filename="filtered.pbf")
    at /usr/include/c++/9.2.1/ext/new_allocator.h:89
#7  osmium::io::Writer::Writer<osmium::io::Header&> (this=0x7fff71736ca0, file=...) at /usr/include/osmium/io/writer.hpp:251
#8  0x00005eb60f5af6a4 in osmium::io::Writer::Writer<osmium::io::Header&> (this=0x7fff71736ca0, filename=...)
    at /usr/include/c++/9.2.1/bits/basic_string.h:263
#9  0x00005eb60f579d8c in main (argc=<optimized out>, argv=<optimized out>) at /home/akh/GIS/osmborder/src/osmborder_filter.cpp:122

The same crash occurs in an existing working docker image (so not related to compilation of osmborder)

Can provide the pbf if you want.

Unable to compile - cannot find osmium

On Ubuntu 16.04:

sudo apt install libosmium2-dev zlib1g-dev
# Installed:  libosmium2-dev: 2.6.0-2    zlib1g-dev:  1:1.2.8.dfsg-2ubuntu4
/mnt/tiles/osmborder$ git clone https://github.com/pnorman/osmborder.git
cd osmborder
mkdir build
cd build
cmake ..

Build results: https://gist.github.com/nyurik/280facb823bda8378ba12cb941aef064

dpkg -L libosmium2-dev shows all headers are in /usr/include/osmium, one file /usr/include/gdalcpp.hpp, and some examples in /usr/share/doc/libosmium2-dev

Also, there is no /usr/include/osmium/version.hpp
per FindOsmium.cmake#L75

Support of disputed_by and claimed_by

It is feasible to support the disputed_by and claimed_by tags? I mean not in the core code, but at least, it's technically doable?

I know these tags are not documented, but there are de facto.

I'm looking for a way to render alternative maps, based on some countries point of view and be able to switch using vector tiles.

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.