I am creating Pandas UDF to calculate the Geometry length since geopandas works on single core .The following is the code which i created to calculate Geometry length.
from pyspark.sql.functions import pandas_udf
import pandas as pd
from shapely import wkt
@pandas_udf('double')
def GeometryLength(geom):
wkt_to_geom=pd.Series(wkt.loads(geom))
wkt_to_geom = wkt_to_geom.to_crs(4326)
return wkt_to_geom.length
Inventory.withColumn("geom_length",GeometryLength(Inventory.geometry))
I am getting an error like PythonException: 'TypeError: Only str is accepted.'