欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

GeoJson介绍

发布时间:2024/3/24 编程问答 52 豆豆
生活随笔 收集整理的这篇文章主要介绍了 GeoJson介绍 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

GeoJson

GeoJson是Json数据(键值对),它是针对地理数据的一个变种

介绍

一个标准的GeoJson如下所示

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

最外层:

  • type:"Feature"表示一个特征要素,"FeatureCollection"表示为特征要素的集合
  • geometry:存储该特征要素的实际形状描述
  • properties:存储该要素的属性

geometry:

  • type:存储要素类型(Point(点),LineString,Polygon,MultiPoint(多点),MultiLineString(多线)和MultiPolygon(多面))

  • coordinates:坐标(存储图形坐标)

Feature

//点-Point {"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[105.380859375,31.57853542647338]} }//多点-MultiPoint {"type":"Feature","properties":{},"geometry":{"type":"MultiPoint","coordinates":[[105.380859375,31.57853542647338],[105.580859375,31.52853542647338]]} }// 线-LineString {"type":"Feature","properties":{},"geometry":{"type":"LineString","coordinates":[[105.6005859375,30.65681556429287],[107.95166015624999,31.98944183792288],[109.3798828125,30.031055426540206],[107.7978515625,29.935895213372444]]} }// 多线-MultiLineString(3维数组) {"type":"Feature","properties":{},"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 {"type":"Feature","properties":{},"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(两个不相交的多边形) {"type": "Feature","properties": {},"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]]]]} }//多多边形-MultiPolygon(两个嵌套的多边形) {"type": "Feature","properties": {},"geometry": {"type": "MultiPolygon","coordinates":[ [[[101.6455078125,27.68352808378776],[114.78515624999999,27.68352808378776],[114.78515624999999,35.209721645221386],[101.6455078125,35.209721645221386],[101.6455078125,27.68352808378776]] ],[[[104.2822265625,30.107117887092357],[108.896484375,30.107117887092357],[108.896484375,33.76088200086917],[104.2822265625,33.76088200086917],[104.2822265625,30.107117887092357]]]]} }//多多边形-MultiPolygon(有孔洞的多边形) {"type": "Feature","properties": {},"geometry": {"type": "MultiPolygon","coordinates":[ [[[101.6455078125,27.68352808378776],[114.78515624999999,27.68352808378776],[114.78515624999999,35.209721645221386],[101.6455078125,35.209721645221386],[101.6455078125,27.68352808378776]],[[104.2822265625,30.107117887092357],[108.896484375,30.107117887092357],[108.896484375,33.76088200086917],[104.2822265625,33.76088200086917],[104.2822265625,30.107117887092357]]]]} }

FeatureCollection

{"type": "FeatureCollection","features": [] }
  • features:可以存在多个feature,并且feature的种类可以不同
{"type": "FeatureCollection","features": [{"type": "Feature","properties": {},"geometry": {"type": "Polygon","coordinates": [[[120.16845703125,29.931134809868684],[119.63562011718751,30.159376896356193],[119.5751953125,30.140376821599734],[119.4708251953125,29.90256760730233],[119.6246337890625,29.401319510041485],[120.0311279296875,29.57345707301757],[120.16845703125,29.931134809868684]]]}},{"type": "Feature","properties": {},"geometry": {"type": "Point","coordinates": [119.63012695312499,30.685163937659564]}},{"type": "Feature","properties": {},"geometry": {"type": "LineString","coordinates": [[118.740234375,29.07057414581467],[119.234619140625,28.806173508854776],[119.80590820312499,28.73394733840369]]}},{"type": "Feature","properties": {},"geometry": {"type": "Polygon","coordinates": [[[119.05334472656249,30.30176068632071],[119.5147705078125,30.30176068632071],[119.5147705078125,30.5717205651999],[119.05334472656249,30.5717205651999],[119.05334472656249,30.30176068632071]]]}}] }

geometryCollection

只存图形

{"type": "GeometryCollection","geometries": [{"type": "Point","coordinates": [108.62, 31.02819]}, {"type": "LineString","coordinates": [[108.896484375,30.1071178870],[108.2184375,30.91717870],[109.5184375,31.2175780]]}] }

总结

以上是生活随笔为你收集整理的GeoJson介绍的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。