Sedona Utilities#

The sedona_utils module provides utility functions for working with Apache Sedona.

class libadalina_core.sedona_utils.EPSGFormats(value)#

Bases: Enum

An enumeration.

libadalina_core.sedona_utils.to_spark_dataframe(df: DataFrame | GeoDataFrame | DataFrame, epsg_format: EPSGFormats | None = None) DataFrame[source]#

Convert a pandas DataFrame or a GeoPandas GeoDataFrame to a Spark DataFrame. If the input is already a Spark DataFrame, it will be returned as is.

This function is useful for converting data to a format suitable for processing with Apache Sedona, however, each function of libadalina already converts the input DataFrame to a Spark DataFrame before processing.

Parameters:
  • df (pandas.DataFrame or geopandas.GeoDataFrame or pyspark.sql.DataFrame) – The DataFrame to convert, which can be a pandas DataFrame, a GeoPandas GeoDataFrame, or a Spark DataFrame.

  • epsg_format (EPSGFormats, optional) – The EPSG format to use for converting the pandas DataFrame. If None is provided and the geometry is missing the EPSG format, libadalina will try to infer the best fitting format.

Returns:

A Spark DataFrame.

Return type:

pyspark.sql.DataFrame