Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Map converter notes
Clone this wiki locally
Where to download public map data
Required packages for converter.py
For a gentoo linux system:
dev-lang/python <= 2.x
Manual install: Shapely
$ tar xf Shapely-*.tar.gz && cd Shapely-* $ python2 setup.py build # python2 setup.py install
# apt-get install python-anyjson python-gdal python-shapely
General usage of
- README.md, which includes a conversion example
- Program synopsis is
converter.py [option]... <input_file> <output_file>, also run
converter.py --helpfor details
- The default values of all command line options can be looked up in the
converter.pysource code, e.g.
parser.add_argument('--name', type=str, default='world')
The input file, usually a
The resulting jVectorMap file (SVG-path as JSON)
Note: This option seems to be unused in the converter script! See option
Field (index is zero-based) of layer-feature that will be used as code to uniquely identify a region in jVectorMap. You can determine the index with tools like
ogrinfo. Beware that the field must be unique for all features, otherwise the map will have missing regions.
Field (index is zero-based) of layer-feature that will be used as label for a region in jVectorMap. You can determine the index with tools like
ogrinfo. Again, beware that even this field must be unique for all features (due to implementation details of
converter.py), otherwise the map will have missing regions.
Use country codes from a tab-separated values file (UTF-8 encoded) with a code/name mapping. The mapping is specified per line using the format
DE Germany. Beware that for each feature there must be a matching code/name mapping.
Optional select criteria, e.g. "ISO = 'DEU'" for only selecting data of Germany. Can also be used to exclude. E.g. Exclude Antarctica: "ne_10m_adm != 'ATA'". Where ne_10m_adm is the field name and ATA is the field value.
Specify the width affecting the scale of the resulting SVG.
FIXME: Yet untested, clarification from the author needed!
Allows to specify additional insets as JSON. Each inset needs to contain an array
codes, which defines the features to use.
FIXME: No clue what this option is for!
Distance between country (outline) boundaries.
To what degree the vector paths may be simplified. Greater values result in less information/details but smaller file size. If this option is not specified or zero, simplification is not being applied.
Use specified rectangle for area clipping. The format is
--viewport "<lng1> <lat1> <lng2> <lat2>", e.g.
--viewport "9.6 48.1 11.3 51.4".
The longitude of the horizontal center of a coordinate system (also called central meridian).
Note: The README.md@88d4d9 incorrectly states that the longitude can be given as string ("10W") while its type is
float. There is already a pull request on this commit.
The map projection to use. Projection names are compatible to those of PROJ.4. Currently implemented projections are
aea(Albers Equal Area)
lcc(Lambert Conformal Conic)
Name of the map, e.g. "Germany". This value will be stored in JSON for informational purpose.
Two-letter language code, e.g. "de". This value will be stored in JSON for informational purpose.
In which encoding the input data is stored, e.g. "utf-8".
Generating maps (examples)
$ python2 converter.py --width 900 --longitude0 11.5 --name world --projection mill --language en public_map_data.shp map_world_mill_en.js
Generate a map of Germany
$ python2 converter.py \ --width 1000 \ --country_name_index 4 \ --country_code_index 30 \ --longitude0 10.71 \ --where "ISO = 'DEU'" \ --projection aea \ --name datag_germany \ --language en \ 10m-admin-1-states-provinces-shp/ne_10m_admin_1_states_provinces_shp.shp \ ../tests/assets/jquery-jvectormap-data-germany-aea-en.js
With v2 of natural earth data, there aren't any ISO attribute, you'll find iso_a2 instead
--where "iso_a2 = 'DE'"
Acquiring map data manually
Support-test and list layers
$ ogrinfo ne_10m_admin_1_states_provinces_shp.shp INFO: Open of `ne_10m_admin_1_states_provinces_shp.shp' using driver `ESRI Shapefile' successful. 1: ne_10m_admin_1_states_provinces_shp (Polygon)
Get all data of layer by layer name
$ ogrinfo -ro ne_10m_admin_1_states_provinces_shp.shp ne_10m_admin_1_states_provinces_shp
Limiting results with provided
WHERE-Clause using argument
-where <condition>. In this example, only list rows where field
$ ogrinfo -ro -where "ISO = 'DEU'" ne_10m_admin_1_states_provinces_shp.shp ne_10m_admin_1_states_provinces_shp
OR : learn to use SAGA-GIS to make your shape file bevore converting it
it is reasonably easy to get a grip on it, it's a very nice GUI with lots of methods. On Ubuntu you can install it from software center
load your natural earth 10m file
workspace/modules/shape tools/select by attribute to select all the region you need
workspace/modules/shape tools/copy selection to new shape layer
workspace/Data/right click on your new layer -> add to map; remove natural earth layer (will free some memory)
workspace/Data/right click on your new layer/attributes/show remove unnecessary fields(most of them, just keep the first one -the code- and the name), update attributes as per your app requirements
workspace/Data/save as shp
use the converter on that shape file, you'll just need to set tolerance, width, language & name
$ python2 /path/to/converter.py \ --width 500 \ --simplify_tolerance 0.044 \ --buffer_distance -0.3 \ --projection mill \ --name ex \ --language en \ /path/to/yourcustommadeshapefile.shp \ /path/to/jquery-jvectormap-ex-mill-en.js
NB: tolerance is relative to the size of shape file (if shape file is the world you'r looking at value around 1000 min, if it is just a country made using this method it is around 0.02 - depending on its size & the level of details you're after