cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Read Geojson file using Sedona Context in Databricks

Kunal_Mishra
New Contributor III

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

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.

2 REPLIES 2

filipniziol
Contributor

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

 

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


 

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group