Skip to content

Extract country regions lightweight TopoJSON files from openstreetmap. Example with french regions.

License

Notifications You must be signed in to change notification settings

karelcallens/regions-topojson

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

regions-topojson

Example with french regions : https://github.com/laem/regions-topojson/blob/master/france/lala.json

Follow these steps to get them for other countries :

Run this command...

wget www.overpass-api.de/api/interpreter --post-file=my.xml -O my.osm

...using this my.xml file.

Just change FR for DE to get german regions for example, and check http://wiki.openstreetmap.org/wiki/Tag:boundary%3Dadministrative to get the 'admin_level' that you need.

<osm-script timeout="1000">
  <!-- gather results -->
  <union>
    <!-- query part for: “admin_level=2” -->
    <query type="relation">
      <has-kv k="admin_level" v="4"/>
      <has-kv k="ISO3166-2" regv="FR-"/>
      
    </query>
  </union>
  <!-- print results -->
  <print mode="body"/>
  <recurse type="down"/>
  <print mode="skeleton" order="quadtile"/>
</osm-script>

Unfortunately, not all country regions on OSM are marked with the ISO3166-2 attribute. E.g. English regions will have to be retrieved using this query lines instead :

<has-kv k="admin_level" v="5"/>
<has-kv k="ref:nuts:1" regv="UK"/>

Then :

npm install osmtogeojson
osmtogeojson my.osm > MYREGIONS.geojson

You can stop here and use geojson, but files will be huge. Simplify them with topojson :

npm install topojson
topojson -o lala.json MYREGIONS.geojson -q 10000 --simplify-proportion 0.02 -p

Developed for qunb.com

About

Extract country regions lightweight TopoJSON files from openstreetmap. Example with french regions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published