通过mapshaper转换为topojson时,QGIS会生成shapefile格式错误 [英] QGIS generated shapefile malformed when converted to topojson by mapshaper

查看:625
本文介绍了通过mapshaper转换为topojson时,QGIS会生成shapefile格式错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我开始一个很小的例子,工作得很好。我使用 QGIS 绘制一行,然后使用 mapshaper 将其转换为 topojson 。然后我使用 D3.js 来加载和可视化它。这是比较大的但不正常的例子:

So I started with a really small example that is working well. I used QGIS to draw a line and then converted it to topojson with mapshaper. Then I use D3.js to load and visualize it. This is the bigger but not working example:


jsfiddle.net/kwoxer/kpL1uyy2/2 /

jsfiddle.net/kwoxer/kpL1uyy2/2/

正如你所看到的,它不会显示一行,它显示疯狂的线条,就像转换错误一样。已经测试过不同的浏览器。

As you can see it not showing just one line, it is showing crazy lines as if the convert gone wrong. Already tested different browsers.

但是正如我所说,我已经用QGIS做了一个小线,转换它,一切都很好。这是线的大小的问题吗?或者转换器?

But as I said I already did a small line before with QGIS, converted it, and everything was fine. So is this an issue of the size of the line? Or by the converter?

这里QGIS的图片在浏览器中应该如何: http://i.imgur.com/s1FPn2P.png

Here a picture from QGIS how it should like in the browser: http://i.imgur.com/s1FPn2P.png

那么什么是创建一个(巨大的)自己的地图并在D3.js中使用它?

So what is a good way to create an (huge) own map and using it in D3.js?

推荐答案

我看着你的小提琴,我想我看到了问题。您正在使用d3的等角映射投影,其预期的长轴坐标与[-180,180]范围内的x值和[-90,90]范围内的y值相关。您的数据集的实际x和y范围是[-991.4407052281722,6787.6906928973385]和[-4789.571699454693,-155.32649155239142]。当d3遇到超出预期范围的坐标时,它会包装它们 - 这就是为什么线条看起来很疯狂。

I looked at your Fiddle, and I think I see the problem. You are using d3's Equirectangular map projection, which expects lat-long coordinates with x values in the range [-180, 180] and y values in the range [-90, 90]. The actual x and y ranges of your dataset are [-991.4407052281722, 6787.6906928973385] and [-4789.571699454693, -155.32649155239142]. When d3 encounters coordinates outside the expected range, it wraps them -- this is why the lines look "crazy."

根据您的坐标值,我猜您正在QGIS项目中使用投影坐标系。要使用d3显示数据,您可以在Lat-long坐标中导出形状(例如,在保存QGIS图层时选择WGS 84作为CRS),或者可以使用d3与投影数据(参见在d3.js中推出已经投影的geoJSON地图

Based on your coordinate values, I'm guessing that you're using a projected coordinate system in your QGIS project. To display the data using d3, you can either export your shapes in lat-long coordinates (e.g. by selecting "WGS 84" as the CRS when saving a QGIS layer), or you can use d3 with projected data (see Drawing already projected geoJSON map in d3.js)

这篇关于通过mapshaper转换为topojson时,QGIS会生成shapefile格式错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆