问题
UPDATE: solved, kind of. I spent some time learning ogr2ogr and topojson and made a topojson that works beautifully in D3. I'm not sure why the file spit out by mapshaper.org turned into shards in my hands; on their site, the file displays fine.
ORIGINAL POST: There may be an answer out there, but how do you ask google "why does my d3 map look like zig zags and shards?" FWIW, "search by image" turned up nothing. ;)
I suspect it's something with wrong projection or wrong conversion from shapefiles? I've been converting via mapshaper.org while I'm learning ogr2ogr and topojson myself.
This should be a map of two Georgia counties, an area maybe 100 miles across. The shapefile came from U.S. Census Tiger.
UPDATE: Tiger's .xml seems to suggest the projection is WGS_1984_Web_Mercator_Auxiliary_Sphere
I got another shapefile of the same area from our state mapping agency and it mapped perfectly.
Any ideas?
d3.json("050_00.json", function(error, counties) {
if (error) return console.error(error);
console.log("ok counties:", counties)
var projection = d3.geo.mercator()
.scale(scale)
.rotate([84.2, -33.9, 0])
var path = d3.geo.path()
.projection(projection);
svg.selectAll("#counties")
.data(topojson.feature(counties, counties.objects['050_00']).features)
.enter().append("path")
.attr("id", "counties")
.attr("d", path)
.attr("opacity", 0.5);
});
来源:https://stackoverflow.com/questions/26132342/d3-toposjon-map-troubleshooting-why-does-it-look-like-all-zig-zags-and-shards