d3 toposjon map troubleshooting … why does it look like all zig zags and shards?

耗尽温柔 提交于 2019-12-11 12:13:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!