geojson格式数据

发布时间 2023-05-24 15:12:55作者: james-roger

可以通过一下地址验证

https://geojson.io/#map=11.2/38.2756/116.7917

一个面数据的情况,

features是一个数组,geometry 的type=Polygon表示一个面数据,可以存放多个面数据,以下就存放了一个面
{
       "type": "FeatureCollection",
       "features": [{
           "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"
               }
           }
       }]
   }

  

geometry 的type=Polygon,存放多个面
{
       "type": "FeatureCollection",
       "features": [{
           "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": "roger"
               
           }
       },{
           "type": "Feature",
           "geometry": {
               "type": "Polygon",
               "coordinates": [
                   [
                       [102.0, 2.0],
						[103.0, 2.0],
						[103.0, 3.0],
						[102.0, 3.0],
						[102.0, 2.0]
                   ]
               ]
           },
           "properties": {
               "prop0": "james"
               
           }
       }]
   }

  

geometry 的type=MultiPolygon,存放多个面
{
	"type": "FeatureCollection",
	"features": [{
		"type": "Feature",
		"geometry": {
			"type": "MultiPolygon",
			"coordinates": [
				[
					[
						[102.0, 2.0],
						[103.0, 2.0],
						[103.0, 3.0],
						[102.0, 3.0],
						[102.0, 2.0]
					]
				],
				[

					[
						[100.2, 0.2],
						[100.2, 0.8],
						[100.8, 0.8],
						[100.8, 0.2],
						[100.2, 0.2]
					]
				]
			]
		},
		"properties": {
			"prop0": "value0",
			"prop1": {
				"this": "that"
			}
		}
	},{
           "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": "roger"
               
           }
       }]
}