Read Geojson file using Sedona Context in Databricks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2024 11:30 PM
Hi Everyone,
I am trying to read a geojson file in Databricks using the following syntax as mentioned in the apache sedona official docs Load Geojson Data
I am using Sedon 1.6.1 Version which supports this feature but i am getting an error as mentioned below
df = sedona.read.format("geojson").option("multiLine", "true").load("PATH/TO/MYFILE.json") .selectExpr("explode(features) as features") # Explode the envelope to get one feature per row. .select("features.*") # Unpack the features struct. .withColumn("prop0", f.expr("properties['prop0']")).drop("properties").drop("type")
Error :
Caused by: java.lang.NoSuchMethodError: org.apache.spark.sql.execution.datasources.json.JsonDataSource.readFile(Lorg/apache/hadoop/conf/Configuration;Lorg/apache/spark/sql/execution/datasources/PartitionedFile;Lorg/apache/spark/sql/catalyst/json/JacksonParser;Lorg/apache/spark/sql/types/StructType;)Lscala/collection/Iterator;
I am using the following Jars and Libraries as mentioned below
- geotools-wrapper-1.6.1-28.2.jar
- sedona-spark-shaded-3.4_2.12-1.6.1.jar (Have tried with sedona-spark-shaded-3.5_2.12-1.6.1.jar also)
I have installed the following libraries
- apache-sedona==1.6.1
- geopandas==0.11.1
- keplergl==0.3.2
- pydeck==0.8.0
Kindly assist me as to how can i fix this. For now i am using spark context to read the geojson file and it is working but i want to use the feature of sedona since it will reduce the number of steps to extract the Polygon Coordinates.
- Labels:
-
Spark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2024 11:41 PM
Hi @Kunal_Mishra ,
The error you are experiencing with Sedona when trying to read a GeoJSON file in Databricks (java.lang.NoSuchMethodError) often indicates a compatibility issue between the Spark version you're using and the Sedona library.
Sedona has specific compatibility requirements with Apache Spark. You need to ensure that the versions of Spark, Scala, and Sedona you are using are all compatible. For example:
- sedona-spark-shaded-3.4_2.12-1.6.1.jar is compatible with Spark 3.4 and Scala 2.12.
- sedona-spark-shaded-3.5_2.12-1.6.1.jar is compatible with Spark 3.5 and Scala 2.12.
Could you check you Databricks Runtime and make sure it is compatible with the sedona version you are using.
Here is the link to check DBR:
https://docs.databricks.com/en/release-notes/runtime/index.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 08:25 PM
Hi @filipniziol , I am using the Databricks Runtime compatible with the Sedona version as mentioned in the jar file.
- DBR Runtime: 14.3 LTS (includes Apache Spark 3.5.0, Scala 2.12)
- Jar File Used : sedona-spark-shaded-3.5_2.12-1.6.1.jar
- Cluster : Single User
As per the comments in the Apache Sedona github issue page
"the Shared Access cluster on Databricks does not allow Spark DataSourceV2. This will prevent you from using Sedona GeoJSON reader/writer, GeoParquet reader/writer. Until Databricks fixes this limitation, you won't be able to use these data sources on Databricks Shared access cluster."
https://github.com/apache/sedona/issues/1617#issuecomment-2405940397

