如何将数据帧转换为Geojson

时间:2018-12-06 11:23:03

标签: json apache-spark-sql geojson

我从数据框中选择列:

  val df4 = predictions.select("coordinates","auswertezeit","geschwindigkeit","strecke_id", "predictedLabel" ).withColumnRenamed("predictedLabel", "verkehrsstatus")

,我想将其转换为具有指定架构的json(Geojson)数据并保存。我有一个示例Geojson数据,如下所示:

{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"MultiLineString","coordinates":[[[7.0847794888,50.7242091272],[7.0859976701,50.7239505872],[7.0895873541,50.7229008357],[7.0901112195,50.7227917786],[7.0906205998,50.7227372113],[7.090896172,50.7227340802],[7.0913044701,50.7227582187],[7.0917071312,50.7228159564],[7.0922891821,50.7229315872],[7.0927992895,50.7230314285],[7.0932376709,50.7230737208],[7.09341669,50.7230667476],[7.0935968504,50.7230439486],[7.0939103789,50.7230019411],[7.0944357092,50.722919812],[7.0946504307,50.722884129]]]},"properties":{"strecke_id":3,"auswertezeit":"2018-11-20T02:25:00","geschwindigkeit":0,"verkehrsstatus":"aktuell nicht ermittelbar"}},{"type":"Feature","geometry":{"type":"MultiLineString","coordinates":[[[7.0946672837,50.7229570868],[7.0944178379,50.7229966536],[7.0941970784,50.7230271005],[7.0939378936,50.7230727802],[7.0936017728,50.7231367597],[7.0932798529,50.7231763907],[7.0930779816,50.7231703081],[7.09282323,50.7231460101],[7.092602118,50.7231125502],[7.0921737342,50.7230305595],[7.0918270299,50.7229575387],[7.091406783,50.7228782479],[7.091032975,50.7228358133],[7.0906586662,50.7228233843],[7.0902282365,50.722859406],[7.0899174596,50.7229079347],[7.0894046068,50.7230325811],[7.0878981056,50.7234669905],[7.0877036425,50.7235309987],[7.087312093,50.7236397914],[7.0870210939,50.7237343579],[7.0867202207,50.7238234119],[7.086342286,50.7239534871],[7.0858559955,50.72409637],[7.0854881812,50.7241892249],[7.0851333403,50.7242715336],[7.0848519142,50.7243477924]]]},"properties":{"strecke_id":4,"auswertezeit":"2018-11-20T02:25:00","geschwindigkeit":55,"verkehrsstatus":"normales Verkehrsaufkommen"}},......]}

0 个答案:

没有答案