2016-12-15 26 views
0

我正在關注Mike Bostocks最新教程topojson at the command line。一切似乎正常工作,當我合併形狀,事情工作,但由於原始形狀文件中的邊緣之間存在小錯誤,我沒有得到適當的合併。具體而言,我試圖合併各國創建大陸。我明白了,我確信我可以找到一個特定的大陸形狀文件,但是我測試了一個過程允許創建可以創建的定製區域。以編程方式或手動編輯topomerge中的錯誤

我看到可以在下面顯示的錯誤:

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

通過反覆試驗,我發現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