node.js - node.js 中的 Geojson 到 Topojson

标签 node.js postgresql-9.1 postgis topojson

我的 postGIS 数据库中有一个形状文件。我已使用以下代码将其检索到 node.js 中的 geojson 中。

var moisql = 'SELECT *, (ST_AsGeoJSON(geom))  from xxx;'

工作正常..但我的要求是我必须将此 geojson 文件转换为“TOPOJSON”。

所以我有这个代码:

topojsonOutput = topojson.topology({'collection': geojsonString});

但我仍在检索 geojson 文件作为输出..所以请指导我实现这一目标..提前致谢。

另外,当我用谷歌搜索时,我得到了这段代码:

var collection = {type: "FeatureCollection", features: […]}; // GeoJSON
var topology = topojson.topology({collection: collection}); // convert to TopoJSON
console.log(topology.objects.collection); // inspect TopoJSON  

但我完全无法理解这一点..我必须提供什么来代替功能[..]和集合..

最佳答案

有一个 PostGIS AsTopoJSON PostGIS 2.1.0 及更高版本可用的功能。或者,有 postgis2geojson转换工具;您可能想看看它如何包装 ST_AsGeoJSON 返回的片段。

关于node.js - node.js 中的 Geojson 到 Topojson,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20779647/

相关文章:

Node.js - 等待文件完全写入

node.js - nodejs child_process.spawnSync 或 child_process.spawn 包裹在返回输出的可屈服生成器中

delphi - Unidac 5.0 性能下降

postgresql - 使用 postgis 通过多边形路径创建一条中间线

python - 如何使用Python提高PostGIS中插入数据的效率?

postgresql - 即使答案为 0,Postgis 也使用包含和计数

javascript - Vue Watch没有触发

JavaScript 术语 : do I (call/invoke/execute) a function?

postgresql - 时间戳列上的 date_trunc 不返回任何内容

node.js - 如果关键字为 null 则获取所有行,否则返回匹配