Topojson源自于GeoJson,是D3中描述地理数据的格式,D3的作者觉得GeoJson太繁琐。同样的数据,TopoJson是GeoJson的1/5。
这里有一个转换TopoJson,GeoJson,Shp的网站http://mapshaper.org/;好像不好使
GeoJson和TopopJson在线转换:http://jeffpaine.github.io/geojson-topojson/
Openlayer3目前支持TopoJson
GeoJson示例
{ "type": "FeatureCollection",
"features": [
{ "type": "Feature",
"geometry": {"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",
"prop1": 0.0
}
},
{ "type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[ [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"}
}
}
]
}
转化为TopoJson示例
{
"type": "Topology",
"objects": {
"collection": {
"type": "GeometryCollection",
"geometries": [
{
"type": "Point",
"coordinates": [
4000,
5000
]
},
{
"type": "LineString",
"arcs": [
0
]
},
{
"type": "Polygon",
"arcs": [
[
1
]
]
}
]
}
},
"arcs": [
[
[
4000,
0
],
[
1999,
9999
],
[
2000,
-9999
],
[
2000,
9999
]
],
[
[
0,
0
],
[
2000,
0
],
[
0,
9999
],
[
-2000,
0
],
[
0,
-9999
]
]
],
"bbox": [
100,
0,
105,
1
],
"transform": {
"scale": [
0.0005000500050005,
0.00010001000100010001
],
"translate": [
100,
0
]
}
}