Scala 如何使用spark提取Geojson模式
我有一个Geojson文件,我想提取与spark对应的模式(structtype)。任何帮助都将不胜感激 我使用spark 2.3.1Scala 如何使用spark提取Geojson模式,scala,apache-spark,apache-spark-sql,geojson,Scala,Apache Spark,Apache Spark Sql,Geojson,我有一个Geojson文件,我想提取与spark对应的模式(structtype)。任何帮助都将不胜感激 我使用spark 2.3.1 Geojson: { "type": "FeatureCollection", "features": [ { "type": "Feature", "geometry": { "type": "MultiLineString", "coordinates": [ [
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中的模式您可以发布您已经尝试过的内容吗。您是否尝试以spark.read.json(“filePath”).schema的形式读取?val data=spark.read.schema(newSchema).json(“hdfs://........./file.json)我尝试从hdfs(file.json)读取geojson数据并提取模式。