Skip to content

一、geoJson数据

1. 是什么

  • json 是通过键值对表示数据对象的一种格式,geoJson 是 json 的子集,用 json 的语法表达和存储地理数据。
  • geoJson 支持以下几何类型:
    • Point
    • LineString
    • Polygon
    • MultiPoint
    • MultiLineString
    • MultiPolygon

二. 具体类型数据结构

1. 单节点

    • 数据结构
      json5
      {
        "type": "FeatureCollection",
        "features": [
          {
            "type": "Feature",
            "properties": {},
            "geometry": {
              "type": "Point",
              "coordinates": [
                105.380859375,
                31.57853542647338
              ]
            }
          }
        ]
      }
    • 示意图 point.png
  • 线

    • 数据结构
      json5
       {
          "type": "FeatureCollection",
          "features": [
            {
              "type": "Feature",
              "properties": {},
              "geometry": {
                "type": "LineString",
                "coordinates": [
                  [
                    109.566650390625,
                    36.4477991295848
                  ],
                  [
                    108.0560302734375,
                    35.303918565311704
                  ]
                ]
              }
            }
          ]
        }
    • 示意图 linestring.png
  • 多边形

    • 数据结构
      json5
      {
        "type": "FeatureCollection",
        "features": [
          {
            "type": "Feature",
            "properties": {},
            "geometry": {
              "type": "Polygon",
              "coordinates": [
                [
                  [
                    107.6220703125,
                    34.939985151560435
                  ],
                  [
                    110.2862548828125,
                    34.939985151560435
                  ],
                  [
                    110.2862548828125,
                    36.491973470593685
                  ],
                  [
                    107.6220703125,
                    36.491973470593685
                  ],
                  [
                    107.6220703125,
                    34.939985151560435
                  ]
                ]
              ]
            }
          }
        ]
      }
    • 示意图
      polygon.png

2. 多节点

  • 多个点

    • 数据结构
      json5
      {
        "type": "FeatureCollection",
        "features": [
          {
            "type": "Feature",
            "properties": {},
            "geometry": {
              "type": "MultiPoint",
              "coordinates": [
                [
                  81.705322265625,
                  53.63161060657857
                ],
                [
                  81.7822265625,
                  54.7943516039205
                ]
              ]
            }
          }
        ]
      }
    • 示意图
      multipoint.png
  • 多条线

    • 数据结构
      json5
      {
        "type": "FeatureCollection",
        "features": [
          {
            "type": "Feature",
            "properties": {},
            "geometry": {
              "type": "MultiLineString",
              "coordinates": [
                  [[10.0, 10.0], [20.0, 20.0], [10.0, 40.0]], 
                  [[40.0, 40.0], [30.0, 30.0], [40.0, 20.0], [30.0, 10.0]]
              ]
            }
          }
        ]
      }
    • 示意图 multi-line-string.png
  • 多个面

    • 数据结构
      json5
      {
        "type": "FeatureCollection",
        "features": [
          {
            "type": "Feature",
            "properties": {},
            "geometry": {
              "type": "MultiPolygon",
              "coordinates": [
                  [
                      [
                        [30.0, 20.0], [45.0, 40.0],
                        [10.0, 40.0], [30.0, 20.0]
                      ]
                  ], 
                  [
                      [
                        [15.0, 5.0], [40.0, 10.0],
                        [10.0, 20.0], [5.0, 10.0], 
                        [15.0, 5.0]
                      ]
                  ]
              ]
            }
          }
        ]
      }
    • 示意图 multi-polygon.png

Released under the MIT License.