I am working on D3.js and want to use Thailand map.
I couldn’t find a shapefile of Thailand so I was asking around (on facebook).
Fortunately, one friend of mine he has one.
So Let’s start.
How to export Shapefile to GeoJson.
Start by downloading GDAL
and run this command in Terminal
/Library/Frameworks/GDAL.framework/Versions/1.9/Programs/ogr2ogr -select “CHA_NE” -f “GeoJSON” -lco COORDINATE_PRECISION=6 output.json input.shp
use -select “fieldname” to specify which field you want to export to the output (default is all fields)
In my case I need only “CHA_NE” field which contains the city/province name.
use -lco COORDINATE_PRECISION to specify how many digit in path data ‘s precision.
If your GeoJson was too big (mine was 18MB).
There are the steps to simplify your Vector
1.Download QGIS and Open your shapefile.
2.Simplify your vector by opening “Vector > Geometry Tools > Simplifies Geometries”
3.Choose your “Simplify tolerance” default is 0.0001. I used 0.0100 and It’s good enough.
4.Save to new Shapefile.
Thailand Geojson for D3.js