Skip to content

Instantly share code, notes, and snippets.

View jiayuasu's full-sized avatar

Jia Yu jiayuasu

View GitHub Profile
val inputFile = "/Users/jiayu/Downloads/Apache_Sedona_Wherobots/gemeinde_de.geojson"
val featuresFile = "/Users/jiayu/Downloads/Apache_Sedona_Wherobots/gemeinde_de_features.geojson"
val geoJson = sparkSession.read.json(inputFile)
geoJson.printSchema()
// Sedona requires that GEOJSON schema has to be Feature, not FeatureCollection
// because a FeatureCollection GeoJSON does NOT follow one geometry per record
// See https://sedona.apache.org/tutorial/rdd/#create-a-generic-spatialrdd
// So we need to separate meta data and features
val metaData = geoJson.select("crs", "source", "type")
metaData.show()