關於GeoJSON
GeoJSON是一種基於JSON的地理空間數據交換格式,它定義了幾種類型JSON對象以及它們組合在一起的方法,以表示有關地理要素、屬性和它們的空間範圍的數據。
一個GeoJSON對象可以是Geometry
, Feature
或者FeatureCollection
Geometry
支援 OpenGIS 簡式特性實作所定義的類型 : Point、LineString、Polygon、MultiPoint、MultiLineString、MultiPolygon 和 GeometryCollection
格式範例如下
{
"type": "Linestring",
"coordinates":
[
[10.0, 11.2],
[10.5, 11.9]
]
}
Feature
由Geometry
加上部分屬性
組成。
部分屬性類似於形狀檔,可包括形狀的屬性或 Placemarks 的 KML 資料夾
格式範例如下
{
"type": "Feature",
"geometry":
{
"type": "Point",
"coordinates":
[10.0, 20.0]
},
"properties":
{
"signpost": "5",
"last_check": "20200701"
}
}
FeatureCollection
簡單來說,就是用來放複數Feature的JSON結構(Feature List)
{
"type": "FeatureCollection",
"features":
[
{
"type":"Feature",
"geometry":
{
"type": "Point",
"coordinates":
[10.0, 5.0]
},
},
{
"type": "Feature",
"geometry":
{
"type": "LineString",
"coordinates":
[
[10.2, 1.0],
[10.3, 2.0],
[10.4, 2.5]
]
},
"properties":
{
"route": "341A7",
"class": "local"
}
}
]
}