GeoJson:一种规范的,基于Javascript对象的地理数据交换格式

已被阅读 1355 次 | 文章分类:gis随笔 | 2018-07-21 16:26

GeoJSON是一种对各种地理数据结构进行编码的格式,基于Javascript对象表示法的地理空间信息数据交换格式。

一:GeoJson对象的几种格式

GeoJSON对象必须有一个名字为"type"的成员。这个成员的值是由GeoJSON对象的类型所确定的字符串。 type成员的值必须是下面之一:"Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon", "GeometryCollection", "Feature", 或者 "FeatureCollection"。

1."type": "FeatureCollection",

                                        
{
    "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"
            }
        }
    }]
}
                                        
                                    

2."type": "feature",

                                        
{
    "type": "feature",
    "geometry": {
            "type": "Point",
            "coordinates": [102.0, 0.5]
        }
}
                                        
                                    

3."type": "GeometryCollection"

                                        
{
    'type':'GeometryCollection',
    'geometries':
        [{
            "type": "LineString",
            "coordinates": [[117.2882028929, 31.864942016], [113.2882028929, 39.864942016], [117.2882028929, 31.864942016]]
        }, {
            "type": "LineString",
            "coordinates": [[117.2882028929, 21.864942016], [112.2882028929, 32.864942016], [117.2882028929, 31.864942016]]
        }]
} ;
                                        
                                    

4."type": "LineString

                                        
{
    "type": "LineString",
    "coordinates": [[117.2882028929, 31.864942016], [113.2882028929, 39.864942016], [117.2882028929, 31.864942016]]
}
                                        
                                    

二:获取GeoJson数据

比如需要使用一些开源库来渲染一副中国省界的Vector地图,那么首先需要获取它的GeoJson数据,怎么获取呢,在这里推荐一个比较好用的工具;访问地址(https://mapshaper.org/);可以实现shape和GeoJson等多种格式互转 使用很简单,首先导入数据,然后选择导出为固定格式

小白GIS

三:获取自定义GeoJson数据

可以将自定义的vector转换为Geojson数据保存 访问地址:http://geojson.io/

小白GIS

QQ:3410192267 | 技术支持 微信:popstarqqsmall

Copyright ©2017 xiaobaigis.com . 版权所有 鲁ICP备17027716号