Install Node (http://nodejs.org/). Use HomeBrew (http://brew.sh/) to install node.
$brew install node
$npm install http-server -g
curl https://npmjs.org/install.sh | sh
$mkdir MyProject
$cd MyProject
$touch index.html
$echo "Hello World" > index.html
$http-server -p 5000 &
$curl -v "http://localhost:5000/index.html"
Note : You can also test by accessing the URL from a browser window.
Note that this would contain the undisputed part of Indian territory only. Google for IND_ADM.zip file (http://archive.lib.msu.edu/maps/public/GISData/ OR http://www.naturalearthdata.com/downloads/10m-cultural-vectors/)
*Unzip the folder IND_ADM and this is what you should see :
├── IND_adm0.csv
├── IND_adm0.dbf
├── IND_adm0.prj
├── IND_adm0.shp
├── IND_adm0.shx
├── IND_adm1.csv
├── IND_adm1.dbf
├── IND_adm1.prj
├── IND_adm1.shp
├── IND_adm1.shx
├── IND_adm2.csv
├── IND_adm2.dbf
├── IND_adm2.prj
├── IND_adm2.shp
├── IND_adm2.shx
├── IND_adm3.csv
├── IND_adm3.dbf
├── IND_adm3.prj
├── IND_adm3.shp
├── IND_adm3.shx
└── read_me.pdf
(source : http://www.naturalearthdata.com/downloads/10m-cultural-vectors/) *Unzip the folder IND_ADM and this is what you should see
├── ne_10m_admin_0_disputed_areas_scale_rank_minor_islands.README.html
├── ne_10m_admin_0_disputed_areas_scale_rank_minor_islands.VERSION.txt
├── ne_10m_admin_0_disputed_areas_scale_rank_minor_islands.cpg
├── ne_10m_admin_0_disputed_areas_scale_rank_minor_islands.dbf
├── ne_10m_admin_0_disputed_areas_scale_rank_minor_islands.prj
├── ne_10m_admin_0_disputed_areas_scale_rank_minor_islands.shp
├── ne_10m_admin_0_disputed_areas_scale_rank_minor_islands.shx
For this we need the following tools installed :
gdal (Geospatial Data Abstraction Library - http://www.gdal.org ) which would also install tool ogr2ogr (http://www.gdal.org/ogr2ogr.html)
$brew install gdal
Install Topojson
$npm install -g topojson
You might need to use sudo if you do get permission denied errors. Now we convert the SHAPE data for INDIA to JSON. Go to the IND_ADM folder and run the following command line :
ogr2ogr -f GeoJSON -where "ADM0_A3 IN ('IND')" IND0.json IND_adm0.shp
ogr2ogr -f GeoJSON -where "ADM0_A3 IN ('IND')" IND1.json IND_adm1.shp
ogr2ogr -f GeoJSON -where "ADM0_A3 IN ('IND')" IND2.json IND_adm2.shp
ogr2ogr -f GeoJSON -where "ADM0_A3 IN ('IND')" IND3.json IND_adm3.shp
Note : All the JSON above would have data only for the undisputed territories of India
ogr2ogr \
-f GeoJSON \
-where "sr_adm0_a3 IN ('IND','PAK','CHN')" \
disputed.json \
ne_10m_admin_0_disputed_areas_scale_rank_minor_islands.shp
Open the disputed.json file.
Copy all the {"type" *} , i.e. the content between '"features": [...]'
Paste the same into '"features":[]' of IND0.json,IND1.json,IND2.json and IND3.json
(Will figure out a better way to do this)
I will provide a TopoJson implementation details of the same later, since geoJSON files are huge. There is a topojson version in the source (india.html)
*I am greatly thankful to Mike Bostock's reference implementation -Lets make a map - "http://bost.ocks.org/mike/map/"