GeoJSON是一种用于编码各种地理数据结构的格式。GeoJSON对象可以表示几何、特征或者特征集合。GeoJSON支持下面几何类型:点、线、面、多点、多线、多面和几何集合。GeoJSON里的特征包含一个几何对象和其他属性,特征集合表示一系列特征。
一个完整的GeoJSON数据结构总是一个JSON对象,符合JSON规范。
GeoJSON官网:https://geojson.org
官网对GeoJSON的规范介绍:https://tools.ietf.org/html/rfc7946
中文翻译后的规范介绍:https://www.oschina.net/translate/geojson-spec
在线验证地址:http://geojson.io/
GeoJSON将地理要素Point、MultiPoint、LineString、MultiLineString、Polygon、MultiPolygon、GeometryCollection封装为一个个要素feature,结构如下:其中geometry下的type即对应上面的地理要素类型
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates":[121.487899486, 31.24916171]
}
}
然后将要素放到一个要素集合里,存放在features集合中,如下:
{
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
121.487899486,
31.24916171
]
}
}]
}
这样即是一个GeoJSON对象
用http://geojson.io/在线验证地址来描绘出点、线
点:
{
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
121.487899486,
31.24916171
]
}
}]
}
多点:
{
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": {},
"geometry": {
"type": "MultiPoint",
"coordinates": [
[121.487899486, 31.24916171],
[121.50, 31.30]
]
}
}]
}
线:
{
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[121.487899486, 31.24916171],
[121.50, 31.30]
]
}
}]
}