我在我的MacOs 10.7.5上安装了gdal 1.10.1和topojson 1.4.0.我已经下载了ne_110m_ocean表格Natural Earth.
我成功地在GeoJSON中转换了形状文件:
ogr2ogr \
-f GeoJSON \
ocean.json \
ne_110m_ocean.shp
Run Code Online (Sandbox Code Playgroud)
然后我将GeoJSON转换为topojson:
topojson \
-o ocean_tj.json \
ocean=ocean.json \
Run Code Online (Sandbox Code Playgroud)
当我使用GeoJSON文件绘图时,一切正常.
d3.json("ocean.json", function(json) {
svg.selectAll("path")
.data(json.features)
.enter()
.append("path")
.attr("d", path)
.style("fill", "steelblue");
});
Run Code Online (Sandbox Code Playgroud)
当我使用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");
});
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?
提前致谢