以编程方式或手动方式编辑topomerge中的错误

时间:2016-12-15 18:18:25

标签: d3.js topojson

我正在跟随Mike Bostocks关于topojson at the command line的最新教程。一切似乎都正常工作,当我合并形状时,事情有效,但由于原始形状文件中的边缘之间存在小的误差,我没有得到适当的合并。具体来说,我试图合并国家来创建大陆。我理解并且我确信我可以找到特定的大陆形状文件,但我测试了一个过程,允许创建可以创建的定制区域。

我看到的错误可以在下面显示:

enter image description here

安哥拉没有与周边国家合并,我不确定原因。

有没有人有经验操作这样的功能才能正常合并?

以下是我为此示例创建的bash脚本(原始形状数据可以下载here):

shp2json ne_110m_admin_0_countries/ne_110m_admin_0_countries.shp -o world-countries.geojson

geostitch world-countries.geojson | geoproject 'd3.geoKavrayskiy7()' > world-countries-projected.geojson

ndjson-split 'd.features' < world-countries-projected.geojson > world-countries.ndjson

ndjson-map 'd.title = d.properties.adm0_a3, d.id = d.properties.adm0_a3, d.continent = d.properties.continent, d' < world-countries.ndjson > world-countries-id.ndjson

geo2svg -n -w 960 -h 960 < world-countries-id.ndjson > world-countries2.svg

geo2topo -n countries=world-countries-id.ndjson > world-countries.topojson

toposimplify -p 2 -f < world-countries.topojson > world-countries-simple.topojson

topoquantize 1e5 < world-countries-simple.topojson > world-countries-quantized.topojson

topomerge -k 'd.continent' continents=countries < world-countries-quantized.topojson > world-continents.topojson

# topomerge --mesh -f 'a !== b' continent=continent < world-continents-merge.topojson > world-continents.topojson

topo2geo continents=world-continents.geojson < world-continents.topojson

geo2svg -w 960 -h 960 < world-continents.geojson > world-continents.svg

1 个答案:

答案 0 :(得分:1)

通过反复试验,我找到了Countries without boundary lakes,创建了更好的合并边界,如下所示:

enter image description here

我的完整脚本在这里:

shp2json ne_50m_admin_0_countries_lakes/ne_50m_admin_0_countries_lakes.shp -o world-countries.geojson

geostitch world-countries.geojson | geoproject 'd3.geoKavrayskiy7()' > world-countries-projected.geojson

ndjson-split 'd.features' < world-countries-projected.geojson > world-countries.ndjson

ndjson-map 'd.title = d.properties.adm0_a3, d.id = d.properties.adm0_a3, d.continent = d.properties.continent, d' < world-countries.ndjson > world-countries-id.ndjson

geo2svg -n -w 960 -h 960 < world-countries-id.ndjson > world-countries2.svg

geo2topo -n countries=world-countries-id.ndjson > world-countries.topojson

toposimplify -p 2 -f < world-countries.topojson > world-countries-simple.topojson

topoquantize 1e5 < world-countries-simple.topojson > world-countries-quantized.topojson

topomerge -k 'd.continent' continents=countries < world-countries-quantized.topojson > world-continents.topojson

topo2geo continents=world-continents.geojson < world-continents.topojson

ndjson-split 'd.features' < world-continents.geojson > world-continents.ndjson

ndjson-map 'd.title = d.id, d' < world-continents.ndjson > world-continents-title.ndjson

geo2svg -n -w 960 -h 960 < world-continents-title.ndjson > world-continents.svg