场景:
我有一个大的(120+MB).geojson文件,它表示一系列LineStrings
特性
下面是使用json.dumps(geoFile['features'][0])
选择的feature
示例:
{
"type": "Feature",
"id": 0,
"properties": {
"FID": 0,
"prop1": 1,
"prop2": "thing2",
"prop3": "thing3"
},
"geometry": {
"type": "LineString",
"coordinates": [
[
-99.491525,
35.306851,
0
],
[
-99.491485,
35.306705,
0
],
[
-99.491451,
35.306581,
0
],
[
-99.491417,
35.306456,
0
],
[
-99.491375,
35.306321,
0
]
]
}
}
目标:
prop1
中的属性值选择一个feature
李>geopandas
地图(或其他python地图)上呈现选定的feature
,以及应用程序中其他地方使用的数据帧中的一些地理参考点李>问题:
properties/prop
从geojson文件中选择feature
的python语法是什么?
[0]
)进行选择,但我找不到通过prop1
进行选择的示例李>json.dumps(geoFile['features'][0]['properties']['prop1'] == 1)
但这只返回true
geopandas
是适合用于这种mashup类型的映射库吗?
Dash
或类似的方法使feature
选择和渲染点交互李>多谢各位
我在这里假设geoFile只是一个python dict,您使用
json.dumps
将其转换为字符串化的json,然后您可以使用字典理解作为这将为您提供满足条件的功能指令列表。 现在你可以用你想要的任何方式来包装它。一个简单的方法是将这个列表放在一个键下,就像初始特性列表放在
"features"
键下一样。json.dumps({"features": features})
相关问题 更多 >
编程相关推荐