我在我的MacOs 10.7.5上安装了gdal 1.10.1和topojson 1.4.0。我已经从Natural Earth下载了ne_110m_ocean文件,下载链接是:http://www.naturalearthdata.com/downloads/110m-physical-vectors/。
我已经成功将该shape文件转换为GeoJSON格式:
我已经成功将该shape文件转换为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");
});
有人可以帮忙吗?
先谢谢了。