GeoJson文件结构

GeoJSON文件使用Json语法,是一种对各种地理数据结构进行编码的格式。

大部分地图软件,都可以生成GeoJson文件,如QGIS。

一些网站也提供GeoJson文件生成服务,例如:

https://datav.aliyun.com/portal/school/atlas/area_selector

https://map.easyv.cloud/

可以通过下面的网站,手工绘制生成GeoJson文件:

https://datav.aliyun.com/portal/school/atlas/area_generator

https://geojson.io/


为方便大家,Foxtable模仿阿里云也做了一个地图编辑器,可以生成字符串形式的经纬度数据(类似行政区域表的数据),而且可以嵌入到自己的管理系统中,你还可以根据需要随意扩展。参考:
一个地图编辑工具

GeoJson文件结构

GeoJson文件就是一个Feature集合,每个Feature对应一个地理元素,例如下面的GeoJson定义了北京和上海两个城市的经纬度位置:

{
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    116.4053,
                    39.905
                ]
            },
            "properties": {
                "name": "北京"
            }
        },
        {
            "type": "Feature",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    121.4726,
                    31.2317
                ]
            },
            "properties": {
                "name": "上海"
            }
        }
    ]
}

Feature元素包括三个节点,其中type节点内容始终都是"Feature";geometry节点包括两个子节点,分别是type和geometry,type用于指定地理元素的类型,geometry同于指定经纬度数据;properties节点的内容不固定,可以包括任意多个子节点 。

数据示例

除了Point,GeoJson有多种类型的数据,分别为:

Point

Point类型对应地图中包含一个标记的VectorPlacemark,其数据格式如下;

{
    "type": "Feature",
    "geometry": {
        "type": "Point",
        "coordinates": [125.6, 10.1]
    },
    "properties": {
        "name": "Dinagat Islands"
    }
}

 

MultiPoint

Point类型对应地图中包含多个标记的VectorPlacemark,其数据格式如下;

{
    "type": "Feature",
    "geometry": {
        "type": "MultiPoint",
        "coordinates": [
            [105.380859375,31.57853542647338],
            [105.580859375,31.52853542647338]
        ]
    }
}

LineString

LineString类型的数据对应地图中仅包含一条线的VectorPolyline,其数据格式示例如下:

{
    "geometry":{
        "type":"LineString",
        "coordinates":[
            [105.6005859375,30.65681556429287],
            [107.95166015624999,31.98944183792288],
            [109.3798828125,30.031055426540206],
            [107.7978515625,29.935895213372444]
        ]
    }
}

MultiLineString

MultiLineString型的数据对应地图控包含多个不连续线条的VectorPolyline ,其数据格式示例如下:

{
    "geometry":{
        "type":"MultiLineString",
        "coordinates":[
            [
                [105.6005859375,30.65681556429287],
                [107.95166015624999,31.98944183792288],
                [109.3798828125,30.031055426540206],
                [107.7978515625,29.935895213372444]
            ],
            [
                [109.3798828125,30.031055426540206],
                [107.1978515625,31.235895213372444]
            ]
        ]
    }
}

Polygon

Polygon型数据对应地图中包含一个多边形的VectorPolygon,其数据格式示例如下:

{
    "geometry":{
        "type":"Polygon",
        "coordinates":[
            [
                [106.10595703125,33.33970700424026],
                [106.32568359375,32.41706632846282],
                [108.03955078125,32.2313896627376],
                [108.25927734375,33.15594830078649],
                [106.10595703125,33.33970700424026]
            ]
        ]
    }
}

MultiPolygon

MultiPolygonl型数据对应地图中包括多个多边形的VectorPolygon ,其数据格式示例如下:

{
    "geometry": {
        "type": "MultiPolygon",
        "coordinates":[
            [
                [
                    [109.2041015625,30.088107753367257],
                    [115.02685546875,30.088107753367257],
                    [115.02685546875,32.7872745269555],
                    [109.2041015625,32.7872745269555],
                    [109.2041015625,30.088107753367257]
                ]
            ],
            [
                [
                    [112.9833984375,26.82407078047018],
                    [116.69677734375,26.82407078047018],
                    [116.69677734375,29.036960648558267],
                    [112.9833984375,29.036960648558267],
                    [112.9833984375,26.82407078047018]
                ]
            ]
        ]
    }
}

 


本页地址:http://www.foxtable.com/webhelp/topics/6153.htm