首页 > 解决方案 > Python 从 Geojson 获取价值

问题描述

请有人可以分享一些python脚本,该脚本将遍历此geojson并检索“附件”下的值。我正在努力解决这些问题。

谢谢

{
 "id": 3,
 "geom": "POINT (-65621.7187500000000000 6688807.5000000000000000)",
 "fields": {
  "Identifier": null,
  "Species": null,
  "Tag_Number": "Quercus robur 505",
},
"extensions": {
"description": null,
"attachment": [
  {
    "id": 7,
    "name": "1531402833735.jpg",
    "size": 4559151,
    "mime_type": "image/jpeg",
    "description": "",
    "is_image": true
  },
  {
    "id": 8,
    "name": "1531402882838.jpg",
    "size": 6418150,
    "mime_type": "image/jpeg",
    "description": "",
    "is_image": true
  }
]
}
}

标签: pythonjsongeojson

解决方案


Please try this below code

 import geojson
 gj = geojson.loads(jsonstr)
 if "attachment" in gj:
     for attachment in gj["attachment"]:
        print (attachment)

推荐阅读