一文看懂GeoJSON

它是什么

GeoJSON is an open standard format designed for representing simple geographical features, along with their non-spatial attributes. It is based on the JavaScript Object Notation (JSON). The features include points (therefore addresses and locations), line strings (therefore streets, highways and boundaries), polygons (countries, provinces, tracts of land), and multi-part collections of these types. GeoJSON features need not represent entities of the physical world only; mobile routing and navigation apps, for example, might describe their service coverage using GeoJSON.
GeoJSON是一种为表示客观世界的地理要素(也包括它们的非空间信息的属性要素)而指定的一个开放的标准,是一种对各种地理数据结构进行编码的格式,它基于JSON数据格式,其描述的地理要素主要包括点、线、面、多点、多线、多面和几何集合,事实上,GeoJSON是对SFS的第一部分简单要素模型的实现,它不仅可以表达真实世界,还可以表示虚拟世界。

一个简单的GeoJson
{ "type": "FeatureCollection",
  "features": [
    { "type": "Feature",
      "geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
      "properties": {"prop0": "value0"}
      },
    { "type": "Feature",
      "geometry": {
        "type": "LineString",
        "coordinates": [
          [102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]
          ]
        },
      "properties": {
        "prop0": "value0",
        "prop1": 0.0
        }
      },
    { "type": "Feature",
       "geometry": {
         "type": "Polygon",
         "coordinates": [
           [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0],
             [100.0, 1.0], [100.0, 0.0] ]
           ]
       },
       "properties": {
         "prop0": "value0",
         "prop1": {"this": "that"}
         }
       }
     ]
   }

可以看出GeoJSON的格式中:

  • Point/LineString/Polygon/MultiPoint/MultiLineString/MultiPolygon/GeometryCollection等地理要素特征对象,typeFeature
  • 每一个Feature具有一个Geometry属性,存储要素的空间属性信息,每一个Feature具有一个properties属性,存储要素的非空间属性信息
  • 相应于OGC SFS规范,在定义空间属性坐标信息即coordinates时,点用一维数组表示,线用二维数组表示,面(有孔/无孔)用三维数组表示,多点用二维数组表示,多线用三维数组表示,多面用四维数组表示;
  • 所有的Feature被包含在features对象里,为一个JSON数组,typeFeatureCollection
表达坐标参考
"crs": {
  "type": "name",
  "properties": {
    "name": "urn:ogc:def:crs:OGC:1.3:CRS84"
    }
}
表达边界
"bbox": [-100.0, -90.0, 100.0, 90.0],

注:这句话可以被定义在Feature or FeatureCollection上。

{"type":"Point","coordinates":[30 20]}
线
{ "type": "LineString","coordinates": [ [100.0, 0.0], [101.0, 1.0] ]}
{
    "type": "Polygon",
    "coordinates": [[ [100.0, 0.0], [101.0, 0.0], [101.0,1.0], [100.0,1.0], [100.0, 0.0] ]]
}
几何集合
{ "type": "GeometryCollection",
  "geometries": [
    { "type": "Point",
      "coordinates": [100.0, 0.0]
      },
    { "type": "LineString",
      "coordinates": [ [101.0, 0.0], [102.0, 1.0] ]
      }
  ]
}
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值