Last active
July 17, 2017 00:52
-
-
Save nobuf/5f2dfb266c909e35b37c95310f06fbcf to your computer and use it in GitHub Desktop.
An exterior rings issue with MLIT's shapefile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<svg width="960" height="600"></svg> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<script src="https://d3js.org/topojson.v3.min.js"></script> | |
<script> | |
var svg = d3.select('svg') | |
// Render Tokyo area | |
var projection = d3.geoMercator() | |
.center([137, 34]) | |
.scale(30000) | |
.translate([-800, 1300]) | |
var path = d3.geoPath() | |
.projection(projection) | |
d3.json('tokyo.json', function (error, jp) { | |
if (error) throw error | |
svg.append('path') | |
.datum(topojson.feature(jp, jp.objects.cities)) | |
.attr('fill', '#eee') | |
.attr('d', path) | |
svg.append('path') | |
.datum(topojson.mesh(jp, jp.objects.cities, function (a, b) { | |
return a === b | |
})) | |
.attr('d', path) | |
.attr('fill', 'none') | |
.attr('stroke', '#333') | |
.attr('stroke-dasharray', '2,2') | |
.attr('stroke-linejoin', 'round') | |
}) | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Choose Tokyo (東京) and download the 2017 data | |
# http://nlftp.mlit.go.jp/ksj/gml/datalist/KsjTmplt-N03-v2_3.html | |
unzip -o -j N03-170101_13_GML.zip -d tmp | |
shp2json -n --encoding sjis tmp/*.shp -o tmp/tokyo.ndjson | |
geo2topo -n cities=tmp/tokyo.ndjson \ | |
| toposimplify -p 0.00002 -f \ | |
> tokyo.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment