1

更新:解决了,有点。我花了一些时间学习 ogr2ogr 和 topojson 并制作了一个在 D3 中运行良好的 topojson。我不确定为什么 mapshaper.org 吐出的文件在我手中变成了碎片;在他们的网站上,该文件显示正常。

原帖:可能有答案,但你怎么问谷歌“为什么我的 d3 地图看起来像锯齿形和碎片?” FWIW,“按图像搜索”一无所获。;)

我怀疑这是错误的投影或 shapefile 的错误转换?在我自己学习 ogr2ogr 和 topojson 的同时,我一直在通过 mapshaper.org 进行转换。

这应该是乔治亚州两个县的地图,面积可能有 100 英里。shapefile 来自美国人口普查老虎。

更新:Tiger 的 .xml 似乎暗示投影是 WGS_1984_Web_Mercator_Auxiliary_Sphere

我从我们的州测绘机构获得了同一区域的另一个 shapefile,它映射得非常完美。

有任何想法吗?

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);
});

这不是乔治亚州迪卡尔布县的地图

4

0 回答 0