Note that there are some explanatory texts on larger screens.

plurals
  1. POPlotting topojson file with d3.js (NYC boroughs and census tracts)
    primarykey
    data
    text
    <p>here is the first <code>topojson</code> 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 <a href="http://bl.ocks.org/4108203" rel="nofollow">this example</a> with a different topojson file. I have uploaded the file <a href="http://temp-share.com/show/FHKdqfs16" rel="nofollow">here</a>. 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.</p> <p>ps: I was unable to tag this as <code>topojson</code> because the tag has not been used before</p> <p><strong>TopoJSON file</strong></p> <p>1) Download shapefile from <a href="http://www.nyc.gov/html/dcp/html/bytes/dwndistricts.shtml" rel="nofollow">here</a></p> <p>(Under “Borough &amp; Community Districts” the file “Boroughs” (left), ArcView Shapefile)</p> <p>2) Simplify shapefile with QGis</p> <p>3) Convert to TopoJSON with</p> <pre><code>ogr2ogr -f geoJSON nybb-geo.json nybb.shp topojson -o nybb.json nybb-geo.json </code></pre> <p><strong>HTML/JS Code</strong></p> <pre><code>&lt;!DOCTYPE html&gt; &lt;meta charset="utf-8"&gt; &lt;style&gt; .boundary { fill: none; stroke: #000; stroke-width: .5px; } &lt;/style&gt; &lt;body&gt; &lt;script src="http://d3js.org/d3.v3.min.js"&gt;&lt;/script&gt; &lt;script src="http://d3js.org/topojson.v0.min.js"&gt;&lt;/script&gt; &lt;script&gt; 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"); }); &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload