如何将海洋形状文件转换为topojson [英] How to convert ocean shape file into topojson
问题描述
我有gdal 1.10.1和topojson 1.4.0安装在我的MacOs 10.7.5。
我已下载 ne_110m_ocean 表单自然地球。
我成功转换了GeoJSON中的形状文件:
ogr2ogr \
-f GeoJSON \
ocean.json \
ne_110m_ocean.shp
然后我将GeoJSON转换为topojson:
topojson \
-o ocean_tj.json \
ocean = ocean.json \
当我使用GeoJSON文件绘图时, / p>
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);
});
任何人都可以帮助?
c>使用选项 - no-force-clockwise
修复
topojson -o ocean_tj.json ocean = ocean.json --no-force-clockwise
I have gdal 1.10.1 and topojson 1.4.0 installed on my MacOs 10.7.5. I have downloaded the ne_110m_ocean form Natural Earth.
I successfully transformed the shape file in GeoJSON:
ogr2ogr \
-f GeoJSON \
ocean.json \
ne_110m_ocean.shp
Then I transformed the GeoJSON into topojson:
topojson \
-o ocean_tj.json \
ocean=ocean.json \
When I plot using the GeoJSON file all works fine.
d3.json("ocean.json", function(json) {
svg.selectAll("path")
.data(json.features)
.enter()
.append("path")
.attr("d", path)
.style("fill", "steelblue");
});
When I plot using the topojson file, instead of having the polygons of the oceans I get the polygons of the lands!!!!
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");
});
Can anyone help?
Thanks in advance
Using the option --no-force-clockwise
fix the issue:
topojson -o ocean_tj.json ocean=ocean.json --no-force-clockwise
这篇关于如何将海洋形状文件转换为topojson的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!