将Big GeoJSON转换成topoJSON [英] Convert Big GeoJSON into topoJSON

查看:379
本文介绍了将Big GeoJSON转换成topoJSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个GeoJSON文件约为1.4 GB,并且由于文件大小(?),命令行工具不起作用.我使用了topojson comman工具,例如:

I have a GeoJSON file that's about 1.4GB, and because of the filesize (?), the command line tool doesn't work. I use topojson comman tool such as:

topojson {{ input file }} >> {{ output file }}

Web工具也有同样的问题(浏览器只是挂起).

Web tools have the same problem (the browser just hangs).

转换巨大的GeoJSON文件的最佳方法是什么?

推荐答案

工具

使用 Topojson命令行应该可以正常工作.该API简短易懂,请快速阅读.

Tool

Using the Topojson command line should works fine. The API is short and well written, read it quickly.

topojson input.json >> output.json # what does `>>` ?

topojson手册告诉我们使用>,切勿使用>>表示append to the output file.所以我想知道这是否可能是错误.

The topojson manual tell us to use >, never the >> which means append to the output file. So I wonder if this could be the bug.

topojson input.json > output.json # convert from geo to topojson.

此命令以相同的质量保留来自geoj​​son输入的所有数据,并将产生+ 250MB的topojson文件.通过客户端上的d3js进行投影时,d3.topojson会尝试将其转换回geojson(1.4GB!),以便d3可以使用它在浏览器中生成接近1GB的svg.这既有自杀性(工作流程将崩溃)又没有意义:topojson旨在通过简化gis数据来适应Web浏览器的较低功能和需求,从而简化您的生活.高清屏幕为1980 * 1280,gis数据远高于此,需要简化.

This command keeps all the data from the geojson input, at same quality, and will result in a +250MB topojson file. When projected via d3js on client side, d3.topojson will try to converted it back into geojson (1.4GB!) so d3 can use it to generate a near 1GB svg in your browser. This is both suicidal (the workflow will crash) and pointless : topojson is designed to ease your life by simplifying gis data to suit web browsers' lower capabilites and needs. HD screens are 1980*1280, gis data are far above this and need simplifications.

使用topojson命令行简化您的巨大geojson数据.常见的简化方法是通过-q 1e4:

Use topojson command line to simplify your huge geojson data. A common simplification is via -q 1e4:

  topojson -q 1e4 \
      -o out.json \
      -- input.geojson

因此,输出文件将具有10.000个伪像素的质量,比输入的质量低很多,但足以满足客户端数据的需要,大约1MB以下.

So the output file will have 10.000 pseudo-pixels quality aka a lot lower than your input yet far enough for client side dataviz, and be about or under 1MB.

这篇关于将Big GeoJSON转换成topoJSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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