【问题标题】:How to Generate Correct GeoJSON and TopoJSON file for Uganda如何为乌干达生成正确的 GeoJSON 和 TopoJSON 文件
【发布时间】:2013-06-29 23:37:44
【问题描述】:

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

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

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

ogr2ogr -f GeoJSON -s_srs EPSG:4199 -t_srs EPSG:4199 districts.json "uganda 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 格式的指示,我将很高兴,因为大多数示例都与美国和其他地区有关。非常感谢您的帮助

【问题讨论】:

  • 你用过 Mike Bostock 的教程吗? bost.ocks.org/mike/map我用它来制作不列颠群岛的形状图。关于从 MVC 加载 JSON,我不得不做一些横向思考,但这并不太费力。
  • @RobLyndon Mikes 教程对这一点非常有帮助,我想我的问题源于它们本身的 shapefile,如果是这种情况,那么如何在生成 geojson 和 topojson 之前更正 shapefile
  • 必须使用您的 shapefile 吗?我对 NaturalEarh's、法国 (L0) 和法国地区以及 makefile 和 d3js 代码进行了类似的工作。轻松移植到乌干达。

标签: maps geojson topojson


【解决方案1】:

首先 - "uganda distriscts.shp" 是什么?为什么文件名中有空格,命令中有引号。您应该拥有所有没有空格的文件,例如 uganda_distriscts.shpugandaDistriscts.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

并检查此线程Map with d3.js and TopoJSON, Albers Siberia projection。我希望这会对你有所帮助。

【讨论】:

  • KoGor 我没有 .prj 文件,到目前为止我可以生成 geojson 和 topojson ,但是生成的 json 文件不能使用 d3 正确渲染。形状文件很容易转换为有效的geojson,可以在这里找到github.com/royowor/uganda-shapefiles.git
  • 好的,试试这个命令:ogr2ogr -f GeoJSON -t_srs EPSG:4326 uganda_distriscts_wgs84.json uganda_distriscts.shp。您可以在此处阅读有关ogr2ogr 的参数。
猜你喜欢
  • 2013-01-22
  • 1970-01-01
  • 2019-11-25
  • 1970-01-01
  • 1970-01-01
  • 2017-09-16
  • 1970-01-01
  • 1970-01-01
  • 2015-07-29
相关资源
最近更新 更多