Created
November 17, 2017 10:41
-
-
Save yohanboniface/31ffe8961091483c9eb67f456a905c51 to your computer and use it in GitHub Desktop.
Extracting international boundaries from OSM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# put here the name of keys for ways that are assumed to be polygons if they are closed | |
# see http://wiki.openstreetmap.org/wiki/Map_Features | |
closed_ways_are_polygons=aeroway,amenity,boundary,building,craft,geological,historic,landuse,leisure,military,natural,office,place,shop,sport,tourism | |
# comment to avoid laundering of keys ( ':' turned into '_' ) | |
attribute_name_laundering=yes | |
# uncomment to report all nodes, including the ones without any (significant) tag | |
#report_all_nodes=yes | |
# uncomment to report all ways, including the ones without any (significant) tag | |
#report_all_ways=yes | |
[multipolygons] | |
# common attributes | |
# note: for multipolygons, osm_id=yes instanciates a osm_id field for the id of relations | |
# and a osm_way_id field for the id of closed ways. Both fields are exclusively set. | |
osm_id=yes | |
osm_version=no | |
osm_timestamp=no | |
osm_uid=no | |
osm_user=no | |
osm_changeset=no | |
# keys to report as OGR fields | |
attributes=name,name:fr,name:en,name:ar,name:es,boundary,border_type,admin_level | |
# keys that should NOT be reported in the "other_tags" field | |
ignore=area,created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME | |
# uncomment to avoid creation of "other_tags" field | |
other_tags=no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the planet (38G) | |
wget https://ftp5.gwdg.de/pub/misc/openstreetmap/planet.openstreetmap.org/pbf/planet-latest.osm.pbf | |
# Install Osmium | |
git clone https://github.com/osmcode/libosmium.git | |
git clone https://github.com/osmcode/osmium-tool.git | |
cd osmium-tool/ | |
mkdir build | |
cd build | |
cmake .. | |
make | |
# Filter boundaries | |
./osmium tags-filter ../../planet-latest.osm.pbf r/admin_level=2 -o ../../boundary.osm.pbf | |
# Transform to SHP with ogr2ogr | |
ogr2ogr --config OSM_CONFIG_FILE boundary.ini -skipfailures boundary.shp boundaries.osm.pbf -sql "SELECT * FROM multipolygons WHERE admin_level='2'" -lco ENCODING=UTF-8 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment