Skip to content

Instantly share code, notes, and snippets.

@chilijung
Last active August 29, 2015 14:04
Show Gist options
  • Save chilijung/f85dcf428596eabaabee to your computer and use it in GitHub Desktop.
Save chilijung/f85dcf428596eabaabee to your computer and use it in GitHub Desktop.
shp to geojson

map testing

shapefiles to geojson

ogr2ogr -f geoJSON kc.json kc.shp

shapefiles info

ogrinfo tl_2010_20_tract10.shp tl_2010_20_tract10
# SCRIPT

# sudo apt-get install npm gdal-bin
# sudo npm install -g mapshaper

# convert shp to geojson & big5 to utf8
mapshaper -p 0.01 --auto-snap -f geojson --encoding big5 -o json/102_05_21_twd97.geo.json 全國村里界圖102.05.21_修正屬性表ID_TWD97/102_05_21台澎金馬修正村里屬性資料_TWD97.shp

# convert geojson polygons from EPSG:3826 to EPSG:4326
ogr2ogr -t_srs EPSG:4326 -s_srs EPSG:3826 -f "GeoJSON" -lco ENCODING=UTF-8 json/102_05_21_4326.geo.json json/102_05_21_twd97.geo.json

# convert geojson to topojson
mapshaper -p 0.01 --auto-snap -f topojson --encoding utf8 -o json/102_05_21_4326.topo.json json/102_05_21_4326.geo.json

epsg 3826: http://spatialreference.org/ref/epsg/twd97-tm2-zone-121/

epgs 4326: http://spatialreference.org/ref/epsg/wgs-84/

tutorial: https://g0v.hackpad.com/GIS-YAuGma5fg7W

read more: http://vallandingham.me/shapefile_to_geojson.html

sample data from: http://www.nlsc.gov.tw/websites/make_page.aspx?la=1&le=2&li=11&sno=136&le2=3&li2=135

Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View raw

(Sorry about that, but we can’t show files that are this big right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment