大家早上好,我是这个世界的新人,所以如果这是一个天真的问题,请原谅我。 我正在使用 OSRM api 服务来获取一些 GPS 轨迹的 map 匹配。我已经通过 Postman 完成了此获取请求:
输出响应应该采用 Geojson 格式,但我在 qgis 中打开它时遇到问题。 所以问题是:如何在 map 中可视化这些类型的结果? 结果代码是这样的:
{
"matchings": [
{
"confidence": 0,
"geometry": {
"coordinates": [
[
9.225701,
45.477585
],
[
9.225701,
45.477592
]
],
"type": "LineString"
},
"legs": [
{
"summary": "",
"weight": 0.1,
"duration": 0.1,
"steps": [],
"distance": 0.8
}
],
"weight_name": "routability",
"weight": 0.1,
"duration": 0.1,
"distance": 0.8
}
],
"tracepoints": [
null,
null,
null,
null,
null,
null,
null,
null,
{
"alternatives_count": 1,
"waypoint_index": 0,
"matchings_index": 0,
"hint": "RZoigAmaIgAiAAAAEAAAAEwAAAATAAAA3yinQZJ9HEEuMTpCgLs6QSIAAAAQAAAATAAAABMAAAB8pgAA5cWMANHutQItxYwA0u61AgMADwC15fcK",
"distance": 14.388305747573964,
"name": "Piazza Leonardo da Vinci",
"location": [
9.225701,
45.477585
]
},
{
"alternatives_count": 1,
"waypoint_index": 1,
"matchings_index": 0,
"hint": "RZoigAmaIgAjAAAADwAAAEwAAAATAAAAI2KtQRELEEEuMTpCgLs6QSMAAAAPAAAATAAAABMAAAB8pgAA5cWMANjutQJBxYwA2e61AgMADwC15fcK",
"distance": 12.824458473911934,
"name": "Piazza Leonardo da Vinci",
"location": [
9.225701,
45.477592
]
}
],
"code": "Ok" }
最佳答案
试试这个:
data = {
"matchings": [
{
"confidence": 0,
"geometry": {
"coordinates": [
[
9.225701,
45.477585
],
[
9.225701,
45.477592
]
],
"type": "LineString"
},
"legs": [
{
"summary": "",
"weight": 0.1,
"duration": 0.1,
"steps": [],
"distance": 0.8
}
],
"weight_name": "routability",
"weight": 0.1,
"duration": 0.1,
"distance": 0.8
}
],
"tracepoints": [
"null",
"null",
"null",
"null",
"null",
"null",
"null",
"null",
{
"alternatives_count": 1,
"waypoint_index": 0,
"matchings_index": 0,
"hint": "RZoigAmaIgAiAAAAEAAAAEwAAAATAAAA3yinQZJ9HEEuMTpCgLs6QSIAAAAQAAAATAAAABMAAAB8pgAA5cWMANHutQItxYwA0u61AgMADwC15fcK",
"distance": 14.388305747573964,
"name": "Piazza Leonardo da Vinci",
"location": [
9.225701,
45.477585
]
},
{
"alternatives_count": 1,
"waypoint_index": 1,
"matchings_index": 0,
"hint": "RZoigAmaIgAjAAAADwAAAEwAAAATAAAAI2KtQRELEEEuMTpCgLs6QSMAAAAPAAAATAAAABMAAAB8pgAA5cWMANjutQJBxYwA2e61AgMADwC15fcK",
"distance": 12.824458473911934,
"name": "Piazza Leonardo da Vinci",
"location": [
9.225701,
45.477592
]
}
],
"code": "Ok" }
def myfunc_map(a, b, c):
return a + b +c
x = map(myfunc_map, data["matchings"], data["tracepoints"], data["code"])
结果:
<map object at 0x0000000004276A20>
关于python - 如何在 map 上可视化得到的响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57707229/