GeoJSON
GeoJSON 是一种对各种地理数据结构进行编码的格式,基于 Javascript对象表示法(JavaScript Object Notation, 简称 JSON)的地理空间信息数据交换格式。
相关链接
- 官方网站:https://geojson.org/ (opens in a new tab)
- 标准文档:https://datatracker.ietf.org/doc/html/rfc7946 (opens in a new tab)
数据示例
{
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [125.6, 10.1]
},
"properties": {
"name": "Dinagat Islands"
}
}]
}
Feature 类型
GeoJSON 支持的 geometry 类型(即 feature 里的 type 值)包括:Point
, LineString
, Polygon
, MultiPoint
, MultiLineString
及 MultiPolygon
点(Point)
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [125.6, 10.1]
},
"properties": {
"name": "Dinagat Islands"
}
}
多点 (MultiPoint)
{
"type": "Feature",
"geometry": {
"type": "MultiPoint",
"coordinates": [
[105.380859375,31.57853542647338],
[105.580859375,31.52853542647338]
]
}
}
其中 coordinates
中的 [125.6, 10.1]
表示一个点位置,同理,线段由多个点组成连线,多边形由多个点组成的填充。
线(LineString)
{
"geometry":{
"type":"LineString",
"coordinates":[
[105.6005859375,30.65681556429287],
[107.95166015624999,31.98944183792288],
[109.3798828125,30.031055426540206],
[107.7978515625,29.935895213372444]
]
}
}
多线(MultiLineString)
{
"geometry":{
"type":"LineString",
"coordinates":[
[
[105.6005859375,30.65681556429287],
[107.95166015624999,31.98944183792288],
[109.3798828125,30.031055426540206],
[107.7978515625,29.935895213372444]
],
[
[109.3798828125,30.031055426540206],
[107.1978515625,31.235895213372444]
]
]
}
}
多边形(Polygon)
{
"geometry":{
"type":"Polygon",
"coordinates":[
[
[106.10595703125,33.33970700424026],
[106.32568359375,32.41706632846282],
[108.03955078125,32.2313896627376],
[108.25927734375,33.15594830078649],
[106.10595703125,33.33970700424026]
]
]
}
}
多多边形 MultiPolygon
{
"geometry": {
"type": "MultiPolygon",
"coordinates":[
[
[
[109.2041015625,30.088107753367257],
[115.02685546875,30.088107753367257],
[115.02685546875,32.7872745269555],
[109.2041015625,32.7872745269555],
[109.2041015625,30.088107753367257]
]
],
[
[
[112.9833984375,26.82407078047018],
[116.69677734375,26.82407078047018],
[116.69677734375,29.036960648558267],
[112.9833984375,29.036960648558267],
[112.9833984375,26.82407078047018]
]
]
]
}
}