How to convert ocean shape file into topojson

一曲冷凌霜 提交于 2019-12-21 14:58:46

问题


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


回答1:


Using the option --no-force-clockwise fix the issue:

topojson -o ocean_tj.json ocean=ocean.json --no-force-clockwise


来源:https://stackoverflow.com/questions/19023995/how-to-convert-ocean-shape-file-into-topojson

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!