2

我已经按照互联网上的所有说明进行操作,但暂时没有结果,我想探索 D3 的 choropleth 地图,此时无法使用 d3 am 堆栈在浏览器中呈现正在生成的 topojson,

到目前为止,我已经下载并安装了 ogr2ogr , Nodejs

正在运行以生成拓扑 json 的命令是

ogr2ogr -f GeoJSON -s_srs EPSG:4199 -t_srs EPSG:4199 Districts.json "乌干达 distriscts.shp"

其次是

topojson --id-property District_i -p District=DIST_2010 -p AREA -p HECTAREAS -o ug.json Districts.json

我对 D3 和 TopoJSON 完全陌生,也不是 GIS 专家。请帮助我克服附加的这个问题,我想生成 topojson 并使用 d3 在 choropleth 地图上渲染它的 shapefile。如果有人可以为我提供有关如何为乌干达生成正确的 topojson 格式的指示,我将很高兴,因为大多数示例都与美国和其他地区有关。您的帮助将不胜感激

4

1 回答 1

2

首先 - 什么是"uganda distriscts.shp"?为什么文件名中有空格,命令中有引号。您应该拥有所有没有空格的文件,例如uganda_distriscts.shpor ugandaDistriscts.shp,并且不需要引号!

第二 - 您应该像这样将您的地图转换为 WGS84:

ogr2ogr -f GeoJSON -s_srs uganda_distriscts.prj -t_srs EPSG:4326 uganda_distriscts_wgs84.json uganda_distriscts.shp

uganda_distriscts.prj是您应该拥有的投影文件,也许它有另一个名称,因此请在文件夹中查找扩展名为.prj.

接下来,您应该像这样创建 TopoJSON 文件:

topojson -o ug.json --id-property district_i -p district=DIST_2010 -p AREA -p HECTAREAS uganda=uganda_distriscts_wgs84.json

并使用 d3.js 和 TopoJSON,Albers Siberia projection检查此线程Map 。我希望这能帮到您。

于 2013-07-03T20:35:44.013 回答