Hi there,
I tried to import my spatial datasets which are stored in a MongoDB in GeoJSON format and run some queries with GeoSpark.
However, I cannot seem to get the import correctly so that I get a spatialRDD. I always get different kind of errors.
Here are the Steps I'm undertaking so far
1. Import collections with the Mongo-Spark-Connector
2. Transforming to DataFrames using a schema and StringTypes for the GeoJSON fields
fails with the error below
boroughs.createOrReplaceTempView("polytable")
var polygonDF = sparkSession.sql(
"""
| SELECT ST_GeomFromGeoJSON(polytable.geometry, polytable._id) AS countyshape
| FROM polytable
""".stripMargin)
var boroughGeoRDD = new SpatialRDD[Geometry]
boroughGeoRDD.rawSpatialRDD = Adapter.toRdd(polygonDF)
ERROR Executor: Exception in task 0.0 in stage 4.0 (TID 4)
java.lang.RuntimeException: com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of double[] out of START_OBJECT token
at [Source: N/A; line: -1, column: -1] (through reference chain: org.wololo.geojson.Polygon["coordinates"]->Object[][0]->Object[][0]->double[][0])
Two questions: Is there a simpler way to import from a MongoDB collection in GeoJSON? and Can anyone help with the shown error?
I tried with two GeoJSON data collections, both work fine with Mongos Spatial Indexes as well as QGIS.
Thank you for any help!!