GeoJSON

因為工作上面,看到了各種形式的GeoJSO,不知道哪種才是正確的,最後才發現原來Geo JSON有支援很多種格式

關於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" 
      }
    }
  ] 
}

ref

Licensed under CC BY-NC-SA 4.0
comments powered by Disqus