我是地理空间数据的新手,我使用HERE API通过使用以下请求url:收集了利雅得的一些交通流量数据
requests.get(f"https://data.traffic.hereapi.com/v7/flow?locationReferencing=shape&in=bbox:46.278534,24.377121,47.040710,25.084355&advancedFeatures=deepCoverage&apiKey={HERE['apikey']}")
他们有三种描述地点的方式,请点击此处:https://developer.here.com/documentation/traffic-api/dev_guide/topics/concepts/location-referencing.html,并且唯一在响应中显示坐标的是Shape Points。我需要带坐标的响应,以便使用地质标准操作和可视化数据,并向每个字符串添加更多数据。然而,反应是这样的:
> {"sourceUpdated": "2022-10-06T14:28:08Z", "results": [{"location": {"description": "u0634u0627u0631u0639
> u0627u0644u0634u064au062e u062eu0644u064au0641u0629
> u0628u0646 u0623u062du0645u062f u0622u0644
> u062bu0627u0646", "length": 288.0, "shape": {"links": [{"points":
> [{"lat": 24.82835004106164, "lng": 46.88801002688706}, {"lat":
> 24.828669978305697, "lng": 46.887639965862036}], "length": 52.0}, {"points": [{"lat": 24.828669978305697, "lng": 46.887639965862036},
> {"lat": 24.828799981623888, "lng": 46.88746998086572}], "length":
> 22.0}, {"points": [{"lat": 24.828799981623888, "lng": 46.88746998086572}, {"lat": 24.829199966043234, "lng": 46.886930018663406}], "length": 70.0}, {"points": [{"lat": 24.829199966043234, "lng": 46.886930018663406}, {"lat": 24.82987998984754, "lng": 46.88601999543607}], "length": 119.0}, {"points": [{"lat": 24.82987998984754, "lng": 46.88601999543607},
> {"lat": 24.830019967630506, "lng": 46.885829977691174}], "length":
> 25.0}]}}, "currentFlow": {"speed": 8.333334, "speedUncapped": 8.333334, "freeFlow": 9.722222, "jamFactor": 0.6, "confidence": 0.71, "traversability": "open"}}, {"location": {"description":
> "u0634u0627u0631u0639 u0627u0644u0635u062du0627u0628u0629",
> "length": 1103.0, "shape": {"links": [{"points": [{"lat":
> 24.803550001233816, "lng": 46.769810020923615}, {"lat": 24.803940011188388, "lng": 46.770779974758625}], "length": 107.0}, {"points": [{"lat": 24.803940011188388, "lng": 46.770779974758625},
> {"lat": 24.804060040041804, "lng": 46.77109002135694}, {"lat":
> 24.804279981181026, "lng": 46.77162000909448}], "length": 93.0}, {"points": [{"lat": 24.804279981181026, "lng": 46.77162000909448},
> {"lat": 24.804349970072508, "lng": 46.77179996855557}], "length":
> 20.0}, {"points": [{"lat": 24.804349970072508, "lng": 46.77179996855557}, {"lat": 24.80441995896399, "lng": 46.771959979087114}], "length": 18.0}, {"points": [{"lat": 24.80441995896399, "lng": 46.771959979087114}, {"lat": 24.80476001277566, "lng": 46.77283002063632}], "length": 96.0}, {"points": [{"lat": 24.80476001277566, "lng": 46.77283002063632},
> {"lat": 24.80492999777198, "lng": 46.77323997952044}], "length":
> 45.0}, {"points": [{"lat": 24.80492999777198, "lng": 46.77323997952044}, {"lat": 24.805459985509515, "lng": 46.77444001659751}], "length": 135.0}, {"points": [{"lat": 24.805459985509515, "lng": 46.77444001659751}, {"lat": 24.805540032684803, "lng": 46.77461000159383}], "length": 19.0}, {"points": [{"lat": 24.805540032684803, "lng": 46.77461000159383},
> {"lat": 24.805650003254414, "lng": 46.77487998269498}], "length":
> 30.0}, {"points": [{"lat": 24.805650003254414, "lng": 46.77487998269498}, {"lat": 24.805780006572604, "lng": 46.77513001486659}], "length": 29.0}, {"points": [{"lat": 24.805780006572604, "lng": 46.77513001486659}, {"lat": 24.805840020999312, "lng": 46.77526001818478}], "length": 15.0}, {"points": [{"lat": 24.805840020999312, "lng": 46.77526001818478},
> {"lat": 24.806040013208985, "lng": 46.77575002424419}], "length":
> 54.0}, {"points": [{"lat": 24.806040013208985, "lng": 46.77575002424419}, {"lat": 24.806360034272075, "lng": 46.7765299603343}], "length": 86.0}, {"points": [{"lat": 24.806360034272075, "lng": 46.7765299603343}, {"lat": 24.80663001537323, "lng": 46.777179976925254}], "length": 72.0}, {"points": [{"lat": 24.80663001537323, "lng": 46.777179976925254},
> {"lat": 24.807410035282373, "lng": 46.77894998341799}], "length":
> 198.0}, {"points": [{"lat": 24.807410035282373, "lng": 46.77894998341799}, {"lat": 24.807629976421595, "lng": 46.77946999669075}], "length": 58.0}, {"points": [{"lat": 24.807629976421595, "lng": 46.77946999669075}, {"lat": 24.80772997252643, "lng": 46.77972002886236}], "length": 28.0}]}}, "currentFlow": {"speed": 8.611112, "speedUncapped": 8.611112,
> "freeFlow": 10.555556, "jamFactor": 1.7, "confidence": 0.94,
> "traversability": "open", "subSegments": [{"length": 819.0, "speed":
> 10.277778, "speedUncapped": 10.277778, "freeFlow": 10.0, "jamFactor": 0.0, "confidence": 0.94, "traversability": "open"}, {"length": 284.0, "speed": 6.111111, "speedUncapped": 6.111111, "freeFlow": 11.388889,
> "jamFactor": 3.1, "confidence": 0.94, "traversability": "open"}]}},
> {"location": {"description": "u0634u0627u0631u0639
> u0627u0644u0628u0631u0642", "length": 180.0, "shape": {"links":
> [{"points": [{"lat": 24.808140015229583, "lng": 46.886649979278445},
> {"lat": 24.808549974113703, "lng": 46.88592997379601}], "length":
> 86.0}, {"points": [{"lat": 24.808549974113703, "lng": 46.88592997379601}, {"lat": 24.80871995911002, "lng": 46.885659992694855}], "length": 33.0}, {"points": [{"lat": 24.80871995911002, "lng": 46.885659992694855}, {"lat": 24.808839987963438, "lng": 46.885469974949956}], "length": 23.0}, {"points": [{"lat": 24.808839987963438, "lng": 46.885469974949956},
> {"lat": 24.808960016816854, "lng": 46.88526998274028}], "length":
> 24.0}, {"points": [{"lat": 24.808960016816854, "lng": 46.88526998274028}, {"lat": 24.809030005708337, "lng": 46.88516001217067}], "length": 14.0}]}}, "currentFlow": {"speed": 5.277778, "speedUncapped": 5.277778, "freeFlow": 8.055555, "jamFactor": 2.5, "confidence": 0.9, "traversability": "open"}},
> {"location": {"description": "u0634u0627u0631u0639
> u0627u0644u0646u062fu0648u0629", "length": 19.0, "shape":
> {"links": [{"points": [{"lat": 24.80036001652479, "lng":
> 46.892340034246445}, {"lat": 24.800450038164854, "lng": 46.8921800237149}], "length": 19.0}]}}, "currentFlow": {"speed": 7.777778, "speedUncapped": 7.777778, "freeFlow": 7.777778, "jamFactor": 0.0, "confidence": 0.84, "traversability": "open"}}, ...
> ] }
如果我错了,请纠正我,这是一个混乱的数据,需要手动进行后处理,以便得到地理标准-fiona驱动程序-的支持,这些驱动程序是:
{'ARCGEN':'r','DXF':'rw','CSV':'raw','OpenFileGDB':'r',"ESRIJSON":"r","ESRI Shapefile":"raw","FlatGeobuf":"rw","GeoJSON":"原始","GeoJSONSeq":"rw","GPKG":"raw","GML":"rw","OGR_GMT":"rw","GPX":"rw","GPSTrackMaker":"rw","Idrisi":"r","MapInfo File":"raw","DGN":"raw","PCIDSK":"原始","OGR_PDS":"r"、"S57":"r","SQLite":"raw","TopoJSON":"r'"}
如果你能告诉我一种方法,我可以以任何支持的格式,或者最好是geojson格式获得数据,我真的会很高兴。
还有一个问题,他们的位置是静态的吗?我的意思是,每次我请求交通数据时,我得到的是相同的路段,但交通数据不同,还是路段会根据交通情况而变化?
谢谢!
HERE api以JSON格式返回数据。数据应该根据用例在应用程序级别进行处理。
第二个查询的答案与分段和流量有关。分段不会更改,只会更新交通数据。