【发布时间】:2013-11-17 10:04:54
【问题描述】:
GIS 到 Topojson:
我使用DIVA-gis.org 作为我的数据源。我已经下载了亚美尼亚行政区域的数据。此下载会生成一个 .shp 文件。我尝试将它直接传递给 topoJSON,我得到一个 json 文件如下
Object {
type: "Topology",
objects: Object,
arcs: Array[1],
transform: Object
}
Topojson 转 SVG:
我将 d3 指向包含我的几何属性的 objects.armenia。问题是几何属性包含一个弧数组,它是 0。现在在我的亚美尼亚 topoJSON 中,我确实看到了一个弧属性数组,其中包含相当大的值数组......我已经尝试将我的 d3 代码指向那个元素,但我仍然一无所获。
除此之外,我还使用 QGIS 将我的 .shp 文件转换为 geoJSON,他们使用 topoJSON 从 geoJSON 到 topoJSON ......但仍然没有。
我的d3代码如下
var width = 960,
height = 500;
var projection = d3.geo.mercator()
.scale(1000)
.translate([width / 2, height / 2]);
var path = d3.geo.path()
.projection(projection);
var mapContainer = d3.select("#armenia").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("/ARM_adm/output.json", function(error, country) {
console.log("country",country)
mapContainer.insert("path", ".graticule")
.datum(topojson.feature(country, country.armenia))
.attr("class", "land")
.attr("d", path);
});
我只是得到了一条空路......任何帮助都会非常感激。
【问题讨论】:
-
如果你使用 GeoJSON 可以吗?
-
我很困惑,你的 topojson 就只有这 6 行代码吗? (约 200 个字符)。如果你也分享你的 ogr / topojson 命令可能会很好。
-
@LarsKotthoff 是的,如果我使用 geoJSON,它确实有效。