【发布时间】:2017-08-24 10:45:12
【问题描述】:
output_buffer = []
for features in range(0,layer.GetFeatureCount()):
feat = layer.GetNextFeature()
geom = feat.GetGeometryRef()
result = feat.ExportToJson()
output_buffer.append(result)
当我转换成 geojson 时,我得到了输出,但只有一个特征被格式化为 JSON
我得到这样的输出:
{"geometry": {"coordinates": [488081.726322771, 2360837.62927308], "type": "Point"}, "type": "Feature", "id": 0, "properties": {"EntityHand": null, "Layer": "pipe", "Linetype": null, "Text": "BB_D2", "ExtendedEn": null, "SubClasses": null}}{"geometry": {"coordinates": [487523.119248441, 2361228.95273474], "type": "Point"}, "type": "Feature", "id": 1, "properties": {"EntityHand": null, "Layer": "pipe", "Linetype": null, "Text": "Mil_D2", "ExtendedEn": null, "SubClasses": null}}..................
我想得到这样的输出:
{"geometry": {"coordinates": [488081.726322771, 2360837.62927308], "type": "Point"}, "type": "Feature", "id": 0, "properties": {"EntityHand": null, "Layer": "pipe", "Linetype": null, "Text": "BB_D2", "ExtendedEn": null, "SubClasses": null}}**,**
{"geometry": {"coordinates": [487523.119248441, 2361228.95273474], "type": "Point"}, "type": "Feature", "id": 1, "properties": {"EntityHand": null, "Layer": "pipe", "Linetype": null, "Text": "Mil_D2", "ExtendedEn": null, "SubClasses": null}}**,**
【问题讨论】:
-
请将您的问题格式化为清晰易读的内容...
-
如果您提供一个工作示例会有所帮助。如果您的问题无法复制,则无法回答。
-
@RutgerKassies。正确的程序是在这种情况下进行适当的近距离投票。
-
你在用什么库?
-
嘿,Srinuvas Bathula:这个答案获得了很多关注,已经快 3 年了。由于这是唯一的答案,并且问题和答案得到了相当多的积极反馈,您介意将其标记为正确吗? :)
标签: python json append shapefile gdal