它是什么
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
等地理要素特征对象,type
为Feature
- 每一个
Feature
具有一个Geometry
属性,存储要素的空间属性信息,每一个Feature
具有一个properties
属性,存储要素的非空间属性信息 - 相应于
OGC SFS
规范,在定义空间属性坐标信息即coordinates
时,点用一维数组表示,线用二维数组表示,面(有孔/无孔)用三维数组表示,多点用二维数组表示,多线用三维数组表示,多面用四维数组表示; - 所有的
Feature
被包含在features
对象里,为一个JSON
数组,type
为FeatureCollection
。
表达坐标参考
"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] ]
}
]
}