Convert Big GeoJSON into topoJSON

老子叫甜甜 提交于 2019-12-06 11:15:35

问题


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 tools have the same problem (the browser just hangs).

What's the best way to convert that huge GeoJSON file?


回答1:


Tool

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

Your command

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

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.

Simple conversion

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

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.

Simplify command

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

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.



来源:https://stackoverflow.com/questions/29037287/convert-big-geojson-into-topojson

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!