This a tool that adapted and simplified POSM-Extractor which is used to parse and export Admin boundaries from OSM data files such as .pbf, .05m using Fences Builder into POSM Extracts similar format.
You need to do the following:
$ sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable
$ sudo apt-get update
$ sudo apt-get install -y libgdal-dev python-dev build-essential libyaml-dev libspatialindex-dev
$ git clone https://github.com/ehealthafrica/mapzen-exporter && cd mapzen-exporter
$ npm install -g fences-builder
$ virtualenv mapzen_env
$ source mapzen_env/bin/activate
$ pip install -r pip-required.txt
$ cd exporter
$ cp settings.yaml.temp settings.yaml
-
In settings.yaml set the following:
-
data_dir
: full path to the input geojson files directory -
output_dir
: full path to output directory -
data_url
: url to OSM data file server -
input_dir
: the path to directory that fences-builder will extract admin levels from OSM data file into. -
country_osm_id: OSM id of the country you want to extract from the data file.
-
admin_levels:
- 2
# Default is 2 for all countries- 4
# OSM Admin level for next sub region for a given country e.g 4 for Nigerian States- 6
# OSM Admin level for next lower admin level for a given country e.g 6 for Nigerian LGAs- 8
#OSM Admin level for next lower admin level for a given country e.g 8 for Nigerian Wards
-
-
To run, while in exporter directory
$ python exproter.py run_all
Ensure that the region selected on the map covers the country you want to extract.
Caveat: for GeoFabrik, Country OSM data file does not extract country boundary use continent's data file or use BBBike and make sure the region selected for extraction covers the country you want to extract its admin levels.
$ nosetests --with-coverage
python exporter.py init_dir
: Initialises empty data directories.python exporter.py download_OSM
: Downloads given OSM data file from remote server.python exporter.py extract_admins
: Extracts OSM data file admin levels as geojson into given input directory.python exporter.py generate_output
: Generates a given country's admin levels and write resulting files to output directorypython exporter.py run_all
: Runs all the above task in one step.