here is the first topojson
question on so. I am having problems rendering a map (NYC boroughs) and can't figure out why. The code below is just a copy of this example with a different topojson file. I have uploaded the file here. Below are also the details about how I created the file. Right now, I am just getting chaotic lines. Probably, the reason is the topojson file but I don't know what's wrong.
ps: I was unable to tag this as topojson
because the tag has not been used before
TopoJSON file
1) Download shapefile from here
(Under “Borough & Community Districts” the file “Boroughs” (left), ArcView Shapefile)
2) Simplify shapefile with QGis
3) Convert to TopoJSON with
ogr2ogr -f geoJSON nybb-geo.json nybb.shp
topojson -o nybb.json nybb-geo.json
HTML/JS Code
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.boundary {
fill: none;
stroke: #000;
stroke-width: .5px;
}
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v0.min.js"></script>
<script>
var width = 960,
height = 500;
var path = d3.geo.path();
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("/geo/nybb.json", function(error, topology) {
svg.append("path")
.datum(topojson.object(topology, topology.objects['nybb-geo'].geometries[0]))
.attr("d", path)
.attr("class", "boundary");
});
</script>