我尝试使用D3.js和TopoJSON构建南非各省的Map。我尝试使用GRASS插件创建GeoJSON输出到QGIS,这似乎有效-我可以在GeoJSON输出中看到各个多边形,以及适当的ID等。我已经将GeoJSON文件转换为TopoJSON文件,我可以在我的finl HTML页面中看到南非的(单个)轮廓,但是我似乎无法在TopoJSON文件中为各省(类似于美国各州)生成多个多边形。我是否需要使用任何特定的参数来强制生成省多边形。我的SVG只有一个路径。
xj3cbfub1#
以下是南非各省的GeoJSON数据集:https://gist.githubusercontent.com/MeganBeckett/9101ba77bd0af06fd003ea5c99d051ab/raw/eca3b12ed76be816c4dce2c0954752b63bd3f804/sa-provinces.json加载此文件,如下所示:
Promise.all([ d3.json("https://gist.githubusercontent.com/MeganBeckett/9101ba77bd0af06fd003ea5c99d051ab/raw/eca3b12ed76be816c4dce2c0954752b63bd3f804/sa-provinces.json"), ]).then(function ([provinces]) { console.log(provinces) });
字符串结果如下:
{type: 'FeatureCollection', name: 'sa-provinces', crs: {…}, features: Array(9)} crs : {type: 'name', properties: {…}} features : Array(9) 0 : {type: 'Feature', properties: {…}, geometry: {…}, id: 'Northern Cape'} 1 : {type: 'Feature', properties: {…}, geometry: {…}, id: 'KwaZulu-Natal'} 2 : {type: 'Feature', properties: {…}, geometry: {…}, id: 'Free State'} 3 : {type: 'Feature', properties: {…}, geometry: {…}, id: 'Eastern Cape'} 4 : {type: 'Feature', properties: {…}, geometry: {…}, id: 'Limpopo'} 5 : {type: 'Feature', properties: {…}, geometry: {…}, id: 'North West'} 6 : {type: 'Feature', properties: {…}, geometry: {…}, id: 'Mpumalanga'} 7 : {type: 'Feature', properties: {…}, geometry: {…}, id: 'Western Cape'} 8 : {type: 'Feature', properties: {…}, geometry: {…}, id: 'Gauteng'} length : 9 [[Prototype]] : Array(0) name : "sa-provinces" type : "FeatureCollection" [[Prototype]] : Object
型图片来源:MeganBeckett(https://twitter.com/meganrogers_za/status/1186585817197830145)
1条答案
按热度按时间xj3cbfub1#
以下是南非各省的GeoJSON数据集:
https://gist.githubusercontent.com/MeganBeckett/9101ba77bd0af06fd003ea5c99d051ab/raw/eca3b12ed76be816c4dce2c0954752b63bd3f804/sa-provinces.json
加载此文件,如下所示:
字符串
结果如下:
型
图片来源:MeganBeckett(https://twitter.com/meganrogers_za/status/1186585817197830145)