一、介绍
GeoJSON 是一种用于表示地理数据的格式,基于 JSON(JavaScript Object Notation)。GeoJSON 支持多种几何对象类型,以及用于描述这些几何对象的特征和集合。
Geometry Objects(几何对象)
- Point
- MultiPoint
- LineString
- MultiLineString
- Polygon
- MultiPolygon
- GeometryCollection
Feature Objects(特征对象)
- Feature特征-标识带有属性的几何对象。一个特征对象包含一个几何对象和一个属性对象。
FeatureCollection Objects(特征集合对象)
- FeatureCollection(特征集合):表示一组特征对象的集合。
二、具体格式
Point
{
"type": "Point",
"coordinates": [30.0, 10.0]
}
MultiPoint
{
"type": "MultiPoint",
"coordinates": [
[10.0, 40.0],
[40.0, 30.0],
[20.0, 20.0],
[30.0, 10.0]
]
}
LineString
{
"type": "LineString",
"coordinates": [
[30.0, 10.0],
[10.0, 30.0],
[40.0, 40.0]
]
}
MultiLineString
{
"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]
]
]
}
Polygon
Polygon用于表示单个多边形。它由一个外环和可选的内环(洞)组成。每个环都是一个线性环(Linear Ring),即一个闭合的线串。外环必须是第一个数组。内环(洞)是可选的,可以有多个。
格式如下:
{
"type": "Polygon",
"coordinates": [
[
[x1, y1], [x2, y2], [x3, y3], ..., [x1, y1] // 外环坐标
],
[
[x4, y4], [x5, y5], [x6, y6], ..., [x4, y4] // 内环坐标(可选)
]
]
}
{
"type": "Polygon",
"coordinates": [
[
[30.0, 10.0],
[40.0, 40.0],
[20.0, 40.0],
[10.0, 20.0],
[30.0, 10.0]
]
]
}
MultiPolygon
每个多边形都有自己的外环和内环(如果有的话)。多边形之间是独立的,可以有多个多边形。
{
"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]
]
]
]
}
GeometryCollection
{
"type": "GeometryCollection",
"geometries": [
{
"type": "Point",
"coordinates": [40.0, 10.0]
},
{
"type": "LineString",
"coordinates": [
[10.0, 10.0],
[20.0, 20.0],
[10.0, 40.0]
]
}
]
}
Feature
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [30.0, 10.0]
},
"properties": {
"name": "Example Point"
}
}
FeatureCollection
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",