My personal blog is:www.ourd3js.com
CSDN Blog for: blog.csdn.net/lzhlzz
Reprint please indicate the source, thank you.
Some days ago a friend message asked GeoJSON file and the relationship between the Topojson file, just I was not very clear, the query after finishing the following, but also hope that we testify.
Both of these files are based on JSON syntax, first of all, what is the JSON syntax and the file.
1. JSON format
JSON (JavaScript Object Notation) is a lightweight data exchange language that is text-based and easy to read. Although JSON is a subset of Javascript, JSON is a language-independent text format and uses some of the same habits as the C language family.
JSON format [1] as follows:
- Object: The data of an object is written within a set of curly braces {...}
- name/value (collection): Each object consists of a series of name/value (collection), separated by a comma (,) between the names/values. A name can be a string, a value can be a string, a value, a Boolean value, a sequence table, or a null value.
Name:value
Because name must be a string, it is written in double quotation marks.
- sequential Table (Array) of values: list is written between [...]
[Collection, Collection, collection, ...]
2. GeoJSON format
GeoJSON is a format for encoding geographic data structures. It is just a format used to describe geographic information in the JSON format described above. its syntax and JSON are the same, but the names are standardized, like [2]:
{"type": "Featurecollection", "features": [{"Type": "Feature", "Geom Etry ": {" type ":" Point "," coordinates ": [102.0, 0.5]}," Properties ": {" prop0 ":" Value0 "}}, {" Type ":" Feature "," geometry ": {" type ":" LineString "," coordinates ": [[102.0, 0.0], [103.0, 1 .0], [104.0, 0.0], [105.0, 1.0]}, "Properties": {"prop0": "Value0", "prop 1 ": 0.0}}, {" Type ":" Feature "," geometry ": {" type ":" Polygon "," coord Inates ": [[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]] ]}, "Properties": {"prop0": "Value0", "Prop1": {"This": ' That '}} } ] }
Specific can participate in the http://geojson.org/
3. Topojson format
Topojson is a simplified version of GeoJSON, which can be said to be a GeoJSON child. The author of D3.js thinks GeoJSON is not very good, and it is more admired Topojson format.
Topojson compared to GeoJSON, the file size is reduced by 80% because:
- The boundary line is recorded only once (for example, the junction lines in Guangxi and Guangdong province are recorded only once)
- Do not use floating-point numbers, use integers only
But Topojson seems to be more widely used in d3.js than in the world-wide format.
Note that, whether GeoJSON or Topojson, they are essentially JSON-formatted files that follow the syntax of JSON, but do not have a different specification for the names of variables.
In http://mapshaper.org/can try to convert the data of GeoJSON and Topojson, we will see that for the same geographic data file, Topojson file size is roughly equivalent to 20% of GeoJSON, which is due to the large amount of file to solve the Reading too slowly is quite simple and effective.
[1] Http://zh.wikipedia.org/wiki/JSON
[2] http://geojson.org/
"D3.js Starter Series-10.3" GeoJSON file and Topojson file differences and links