# GeoJson

GeoJson是Json数据(键值对),它是针对地理数据的一个变种

# 介绍

一个标准的GeoJson如下所示

{
  "type": "Feature",
  "geometry": {
    "type": "Point",
    "coordinates": [125.6, 10.1]
  },
  "properties": {
    "name": "Dinagat Islands"
  }
}
1
2
3
4
5
6
7
8
9
10

最外层:

  • type:"Feature"表示一个特征要素,"FeatureCollection"表示为特征要素的集合
  • geometry:存储该特征要素的实际形状描述
  • properties:存储该要素的属性

geometry:

  • type:存储要素类型(Point(点),LineString,Polygon,MultiPoint(多点),MultiLineString(多线)和MultiPolygon(多面))

  • coordinates:坐标(存储图形坐标)

# Feature

//点-Point
{"type":"Feature",
 "properties":{},
 "geometry":{
   "type":"Point",
   "coordinates":[105.380859375,31.57853542647338]
 }
}

//多点-MultiPoint
{"type":"Feature",
 "properties":{},
 "geometry":{
   "type":"MultiPoint",
   "coordinates":[[105.380859375,31.57853542647338],
                  [105.580859375,31.52853542647338]
                 ]
 }
}

// 线-LineString
{"type":"Feature",
 "properties":{},
 "geometry":{
   "type":"LineString",
   "coordinates":[[105.6005859375,30.65681556429287],
                  [107.95166015624999,31.98944183792288],
                  [109.3798828125,30.031055426540206],
                  [107.7978515625,29.935895213372444]]
 }
}

// 多线-MultiLineString(3维数组)
{"type":"Feature",
 "properties":{},
 "geometry":{
   "type":"MultiLineString",
   "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
{"type":"Feature",
 "properties":{},
 "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(两个不相交的多边形)
{
  "type": "Feature",
  "properties": {},
  "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]
        ]
      ]
    ]
  }
}

//多多边形-MultiPolygon(两个嵌套的多边形)
{
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "MultiPolygon",
    "coordinates":
    [ 
      [
        [
          [101.6455078125,27.68352808378776],
          [114.78515624999999,27.68352808378776],
          [114.78515624999999,35.209721645221386],
          [101.6455078125,35.209721645221386],
          [101.6455078125,27.68352808378776]
        ]   
      ],
      [
        [
          [104.2822265625,30.107117887092357],
          [108.896484375,30.107117887092357],
          [108.896484375,33.76088200086917],
          [104.2822265625,33.76088200086917],
          [104.2822265625,30.107117887092357]
        ]
      ]
    ]
  }
}

//多多边形-MultiPolygon(有孔洞的多边形)
{
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "MultiPolygon",
    "coordinates":
    [ 
      [
        [
          [101.6455078125,27.68352808378776],
          [114.78515624999999,27.68352808378776],
          [114.78515624999999,35.209721645221386],
          [101.6455078125,35.209721645221386],
          [101.6455078125,27.68352808378776]


        ],
        [
          [104.2822265625,30.107117887092357],
          [108.896484375,30.107117887092357],
          [108.896484375,33.76088200086917],
          [104.2822265625,33.76088200086917],
          [104.2822265625,30.107117887092357]

        ]
      ]
    ]
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162

# FeatureCollection

{
  "type": "FeatureCollection",
  "features": []
}
1
2
3
4
  • features:可以存在多个feature,并且feature的种类可以不同
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              120.16845703125,
              29.931134809868684
            ],
            [
              119.63562011718751,
              30.159376896356193
            ],
            [
              119.5751953125,
              30.140376821599734
            ],
            [
              119.4708251953125,
              29.90256760730233
            ],
            [
              119.6246337890625,
              29.401319510041485
            ],
            [
              120.0311279296875,
              29.57345707301757
            ],
            [
              120.16845703125,
              29.931134809868684
            ]
          ]
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [
          119.63012695312499,
          30.685163937659564
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "LineString",
        "coordinates": [
          [
            118.740234375,
            29.07057414581467
          ],
          [
            119.234619140625,
            28.806173508854776
          ],
          [
            119.80590820312499,
            28.73394733840369
          ]
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              119.05334472656249,
              30.30176068632071
            ],
            [
              119.5147705078125,
              30.30176068632071
            ],
            [
              119.5147705078125,
              30.5717205651999
            ],
            [
              119.05334472656249,
              30.5717205651999
            ],
            [
              119.05334472656249,
              30.30176068632071
            ]
          ]
        ]
      }
    }
  ]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107

# geometryCollection

只存图形

{
  "type": "GeometryCollection",
  "geometries": [
    {
      "type": "Point",
      "coordinates": [108.62, 31.02819]
    }, {
      "type": "LineString",
      "coordinates": [[108.896484375,30.1071178870],
                      [108.2184375,30.91717870],
                      [109.5184375,31.2175780]]
    }]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
上次更新时间: 2022年5月20日星期五上午11点16分