I am converting the map file in Bostock's US Atlas (the unfiltered-us-states shp file) to topojson. And I end up with this map. Does anyone know why?
My projection code: var svg = d3.select("#interactive").insert("svg") .attr("width", w) .attr("height", h);
var projection = d3.geo.albers().scale([600]);
var path = d3.geo.path().projection(projection);
d3.json("us-states.json", function(error, us) {
if (error) return console.error(error);
svg.append("path")
.datum(topojson.mesh(us))
.attr("d", path);
});
Original files I've tried (doing the same thing): 12, Converted files: 12,
shp
file (whatever that is) contains state border segments (e.g. the Texas-Oklahoma border, the Texas-New Mexico border), while topojson expects complete state borders (e.g. the boundary of Texas, all the way around). There may be other problems too. – Betatopojson.mesh(topology)
returns a single path representing all the borders in that topology as multiple open-ended sub-paths. This is exactly what your map displays, except that your map has the default path styling of black fill and no stroke, which doesn't make sense for a path that only represents borders. If you just want to draw the borders, set.style({fill:"none", stroke:"black"});
on the path. If you want each state to be a separate filled path, you're going to need a different approach. – AmeliaBR