I am having a lot of fun playing with topojson, but it looks like topojson.object is undefined in V1 of topojson, where it was supported in V0. Can someone explain how I might work around this issue? I am trying to draw distinct path elements for each polygon in an input file formatted as topojson. the code is:
d3.json("maTopo.json", function(error, ma) {
svg.selectAll(".subunit")
.data(topojson.object(ma, ma.objects.ma).geometries)
.enter().append("path")
.attr("class", function(d) { return "subunit " + d.id; })
.attr("d", path);
});
TopoJSON is an extension of GeoJSON that encodes topology. Rather than representing geometries discretely, geometries in TopoJSON files are stitched together from shared line segments called arcs. This technique is similar to Matt Bloch's MapShaper and the Arc/Info Export format, .
You can use topojson.feature
instead.
d3.json("maTopo.json", function(error, ma) {
svg.selectAll(".subunit")
.data(topojson.feature(ma, ma.objects.ma).features)
.enter().append("path")
.attr("class", function(d) { return "subunit " + d.id; })
.attr("d", path);
});
A detailed example can be found here: http://bost.ocks.org/mike/map/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With