我在 MacOs 10.7.5 上安装了 gdal 1.10.1 和 topojson 1.4.0。
我已经下载了 ne_110m_ocean形成自然地球。
我成功地转换了 GeoJSON 中的形状文件:
ogr2ogr \
-f GeoJSON \
ocean.json \
ne_110m_ocean.shp
然后我将 GeoJSON 转换为 topojson:
topojson \
-o ocean_tj.json \
ocean=ocean.json \
当我使用 GeoJSON 文件绘图时,一切正常。
d3.json("ocean.json", function(json) {
svg.selectAll("path")
.data(json.features)
.enter()
.append("path")
.attr("d", path)
.style("fill", "steelblue");
});
当我使用 topojson 文件绘图时,我得到的是陆地的多边形,而不是海洋的多边形!!!!
d3.json("ocean_tj.json", function(topology) {
var ocean = topojson.feature(topology, topology.objects.ocean);
svg.append("path")
.datum(ocean)
.attr("d", path)
.style("fill", "red");
});
任何人都可以帮忙吗?
提前致谢
最佳答案
使用选项 --no-force-clockwise
修复问题:
topojson -o ocean_tj.json ocean=ocean.json --no-force-clockwise
关于d3.js - 如何将海洋 shapefile 转换为 topojson,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19023995/