(Map drawing algorithm itself is in script.js
)
Get map path data source for rendering from the public-domain Natural Earth -> "Download" tab -> "Cultural" of "Large Scale data 1:10m" -> "Download states and provinces" of "Admin 1 - States Provinces"
$ wget http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/1
0m/cultural/ne_10m_admin_1_states_provinces.zip
The zip file includes several files of "shapefile" format:
$ unzip -t ne_10m_admin_1_states_provinces.zip
Archive: ne_10m_admin_1_states_provinces.zip
testing: ne_10m_admin_1_states_provinces.README.html OK
testing: ne_10m_admin_1_states_provinces.VERSION.txt OK
testing: ne_10m_admin_1_states_provinces.cpg OK
testing: ne_10m_admin_1_states_provinces.dbf OK
testing: ne_10m_admin_1_states_provinces.prj OK
testing: ne_10m_admin_1_states_provinces.shp OK
testing: ne_10m_admin_1_states_provinces.shx OK
No errors detected in compressed data of ne_10m_admin_1_states_provinces.zip.
Using "shape" files in the zip includes area data (prefectures all over the world)
$ unzip ne_10m_admin_1_states_provinces.zip
Pickup Japan prefectures to store as GeoJSON format with a command in gdal
$ brew install gdal
$ ogr2ogr -f GeoJSON -where `geonunit="Japan"` japan.geo.json \
ne_10m_admin_1_states_provinces.shp
Japan Prefectures GeoJSON structure is:
{
type: "FeatureCollection",
features: [ // 48 objects, 0 is "Japan minor island" (most props are null)
{
type: "Feature",
properties: {
...
name: "Hiroshima", //nul
name_local: "広島県",//null
type: "Ken", // null,
region: "Chugoku", //null,
gn_name: "Hiroshima-ken",
provnum_ne: 11, // 0, 2-49 ?
gn_a1_code: "JP.11", //null, JP.01 - JP.47
gns_adm1: "JA11", //null, JA01-JA47
...
},
geometry: {
type: "MultiPolygon",
coordinates: [
[
[
[longitude, latitude], ... //0th and last are same (closed path)
] // 1 element?
],
...
]
}
},
...
{
type: "Feature",
properties: {...},
geometry: {
type: "Polygon",
coordinates: [
[
[longitude, latitude], ... //0th and last are same (closed path)
] // 1 element?
]
}
}
]// 48
}
- NOTE:
features[20].properties.name_local
isnull
(should fix as "静岡県") - NOTE: In "states and provinces" data, only "MultiPolygon" and "Polygon" are used.
- See: GeoJSON spec of the geometry structures
- For acquiring and processing Japan map data is based on: http://y-uti.hatenablog.jp/entry/2014/02/09/071953
demo: https://rawgit.com/bellbind/0df729bca4ad7f11fabc/raw/index.html