Getting an error when trying to run an example given in the Mosaic website: https://databrickslabs.github.io/mosaic/api/spatial-functions.html#st-centroid2d
Code:
from mosaic import enable_mosaic
import mosaic as mos
enable_mosaic(spark, dbutils)
from pyspark.sql.functions import *
df = spark.createDataFrame([{'wkt': 'POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))'}])
df.select(mos.st_centroid2D('wkt')).show()
Result:
Error: AttributeError: module 'mosaic' has no attribute 'st_centroid2D'
This is tried on Microsoft Azure Databricks.
Versions: Mosaic - 0.3.9; Databricks Runtime Version - 11.3 LTS (includes Apache Spark 3.3.0, Scala 2.12)
Can you please help to fix this issue?
It's a bug in the documentation that wasn't updated to reflect the change made to remove
st_centroid2Dandst_centroid3Dfunctions. Instead of that function you need to use thest_centroidfunction that will return a WKT object:will give:
Documentation will be corrected soon.