如何使用 spark 提取 Geojson Schema

How to extract Geojson Schema with spark

我有一个 Geojson 文件,我想提取与 spark 对应的模式(结构类型)。任何帮助将不胜感激

我用的是spark 2.3.1

Geojson:
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "MultiLineString",
        "coordinates": [
          [
            [
              7.0847794888,
              50.7242091272
            ],
            [
              7.0859976701,
              50.7239505872
            ],
             ...
            [
              7.0946504307,
              50.722884129
            ]
          ]
        ]
      },
      "properties": {
        "strecke_id": 3,
        "auswertezeit": "2018-11-13T16:10:00",
        "geschwindigkeit": 26,
        "verkehrsstatus": "erh�hte Verkehrsbelastung"
      }
    },.....

感谢您的帮助

val data = spark.read.json("hdfs://........./file.json")
val schema = data.schema

这应该为您提供 StructType 中的模式