sedona.spark.sql package

Submodules

sedona.spark.sql.connect module

sedona.spark.sql.dataframe_api module

class sedona.spark.sql.dataframe_api.ConnectColumn[source]

Bases: object

sedona.spark.sql.dataframe_api.call_sedona_function(object_name: str, function_name: str, args: Any | Tuple[Any]) Column[source]
sedona.spark.sql.dataframe_api.is_remote()[source]
sedona.spark.sql.dataframe_api.validate_argument_types(f: Callable) Callable[source]

Validates types of arguments passed to a dataframe API style function. Arguments will need to be either strings, columns, or match the typehints of f. This function is meant to be used a decorator.

Parameters:

f (Callable) – Function to validate for.

Returns:

f wrapped with type validation checks.

Return type:

Callable

sedona.spark.sql.exceptions module

exception sedona.spark.sql.exceptions.GeometryUnavailableException(message)[source]

Bases: Exception

__init__(message)[source]
exception sedona.spark.sql.exceptions.InvalidGeometryException(message)[source]

Bases: Exception

__init__(message)[source]

sedona.spark.sql.functions module

exception sedona.spark.sql.functions.InvalidSedonaUDFType[source]

Bases: Exception

class sedona.spark.sql.functions.SedonaUDFType(value)[source]

Bases: Enum

GEO_SERIES = 'GeoSeries'
SHAPELY_SCALAR = 'ShapelyScalar'
sedona.spark.sql.functions.deserialize_geometry_if_geom(data)[source]
sedona.spark.sql.functions.sedona_vectorized_udf(return_type: DataType, udf_type: SedonaUDFType = SedonaUDFType.SHAPELY_SCALAR)[source]
sedona.spark.sql.functions.serialize_to_geometry_if_geom(data, return_type: DataType)[source]

sedona.spark.sql.st_aggregates module

sedona.spark.sql.st_aggregates.ST_Envelope_Aggr(geometry: Column | ConnectColumn | str) Column[source]

Aggregate Function: Get the aggregate envelope of a geometry column.

Parameters:

geometry (ColumnOrName) – Geometry column to aggregate.

Returns:

Geometry representing the aggregate envelope of the geometry column.

Return type:

Column

sedona.spark.sql.st_aggregates.ST_Intersection_Aggr(geometry: Column | ConnectColumn | str) Column[source]

Aggregate Function: Get the aggregate intersection of a geometry column.

Parameters:

geometry (ColumnOrName) – Geometry column to aggregate.

Returns:

Geometry representing the aggregate intersection of the geometry column.

Return type:

Column

sedona.spark.sql.st_aggregates.ST_Union_Aggr(geometry: Column | ConnectColumn | str) Column[source]

Aggregate Function: Get the aggregate union of a geometry column.

Parameters:

geometry (ColumnOrName) – Geometry column to aggregate.

Returns:

Geometry representing the aggregate union of the geometry column.

Return type:

Column

sedona.spark.sql.st_constructors module

sedona.spark.sql.st_constructors.ST_GeogFromWKT(wkt: Column | ConnectColumn | str, srid: Column | ConnectColumn | str | float | int | None = None) Column[source]

Generate a geography column from a Well-Known Text (WKT) string column.

Parameters:

wkt (ColumnOrName) – WKT string column to generate from.

Returns:

Geography column representing the WKT string.

Return type:

Column

sedona.spark.sql.st_constructors.ST_GeomCollFromText(wkt: Column | ConnectColumn | str, srid: Column | ConnectColumn | str | float | int | None = None) Column[source]

Generate GeometryCollection geometry from a GeometryCollection WKT representation.

Parameters:
  • wkt (ColumnOrName) – GeometryCollection WKT string column to generate from.

  • srid (ColumnOrNameOrNumber) – SRID for the geometry

Returns:

GeometryCollection geometry generated from the wkt column.

Return type:

Column

sedona.spark.sql.st_constructors.ST_GeomFromEWKB(wkb: Column | ConnectColumn | str) Column[source]

Generate a geometry column from a Well-Known Binary (WKB) binary column.

Parameters:

wkb (ColumnOrName) – WKB binary column to generate from.

Returns:

Geometry column representing the WKB binary.

Return type:

Column

sedona.spark.sql.st_constructors.ST_GeomFromEWKT(ewkt: Column | ConnectColumn | str) Column[source]

Generate a geometry column from a OGC Extended Well-Known Text (WKT) string column.

Parameters:

ewkt (ColumnOrName) – OGC Extended WKT string column to generate from.

Returns:

Geometry column representing the EWKT string.

Return type:

Column

sedona.spark.sql.st_constructors.ST_GeomFromGML(gml_string: Column | ConnectColumn | str) Column[source]

Generate a geometry column from a Geography Markup Language (GML) string column.

Parameters:

gml_string (ColumnOrName) – GML string column to generate from.

Returns:

Geometry column representing the GML string.

Return type:

Column

sedona.spark.sql.st_constructors.ST_GeomFromGeoHash(geohash: Column | ConnectColumn | str, precision: Column | ConnectColumn | str | int) Column[source]

Generate a geometry column from a geohash column at a specified precision.

Parameters:
  • geohash (ColumnOrName) – Geohash string column to generate from.

  • precision (Union[ColumnOrName, int]) – Geohash precision to use, either an integer or an integer column.

Returns:

Geometry column representing the supplied geohash and precision level.

Return type:

Column

sedona.spark.sql.st_constructors.ST_GeomFromGeoJSON(geojson_string: Column | ConnectColumn | str) Column[source]

Generate a geometry column from a GeoJSON string column.

Parameters:

geojson_string (ColumnOrName) – GeoJSON string column to generate from.

Returns:

Geometry column representing the GeoJSON string.

Return type:

Column

sedona.spark.sql.st_constructors.ST_GeomFromKML(kml_string: Column | ConnectColumn | str) Column[source]

Generate a geometry column from a KML string column.

Parameters:

kml_string (ColumnOrName) – KML string column to generate from.

Returns:

Geometry column representing the KML string.

Return type:

Column

sedona.spark.sql.st_constructors.ST_GeomFromText(wkt: Column | ConnectColumn | str, srid: Column | ConnectColumn | str | float | int | None = None) Column[source]

Generate a geometry column from a Well-Known Text (WKT) string column. This is an alias of ST_GeomFromWKT.

Parameters:

wkt (ColumnOrName) – WKT string column to generate from.

Returns:

Geometry column representing the WKT string.

Return type:

Column

sedona.spark.sql.st_constructors.ST_GeomFromWKB(wkb: Column | ConnectColumn | str) Column[source]

Generate a geometry column from a Well-Known Binary (WKB) binary column.

Parameters:

wkb (ColumnOrName) – WKB binary column to generate from.

Returns:

Geometry column representing the WKB binary.

Return type:

Column

sedona.spark.sql.st_constructors.ST_GeomFromWKT(wkt: Column | ConnectColumn | str, srid: Column | ConnectColumn | str | float | int | None = None) Column[source]

Generate a geometry column from a Well-Known Text (WKT) string column. This is an alias of ST_GeomFromText.

Parameters:

wkt (ColumnOrName) – WKT string column to generate from.

Returns:

Geometry column representing the WKT string.

Return type:

Column

sedona.spark.sql.st_constructors.ST_GeometryFromText(wkt: Column | ConnectColumn | str, srid: Column | ConnectColumn | str | float | int | None = None) Column[source]

Generate a geometry column from a Well-Known Text (WKT) string column. This is an alias of ST_GeomFromWKT.

Parameters:

wkt (ColumnOrName) – WKT string column to generate from.

Returns:

Geometry column representing the WKT string.

Return type:

Column

sedona.spark.sql.st_constructors.ST_LineFromText(wkt: Column | ConnectColumn | str) Column[source]

Generate linestring geometry from a linestring WKT representation.

Parameters:

wkt (ColumnOrName) – Linestring WKT string column to generate from.

Returns:

Linestring geometry generated from the wkt column.

Return type:

Column

sedona.spark.sql.st_constructors.ST_LineFromWKB(wkb: Column | ConnectColumn | str, srid: Column | ConnectColumn | str | float | int | None = None) Column[source]

Generate a Line geometry column from a Well-Known Binary (WKB) binary column.

Parameters:
  • wkb (ColumnOrName) – WKB binary column to generate from.

  • srid (ColumnOrNameOrNumber) – SRID to be set for the geometry.

Returns:

Geometry column representing the WKB binary.

Return type:

Column

sedona.spark.sql.st_constructors.ST_LineStringFromText(coords: Column | ConnectColumn | str, delimiter: Column | ConnectColumn | str) Column[source]

Generate a linestring geometry column from a list of coords separated by a delimiter in a string column.

Parameters:
  • coords (ColumnOrName) – String column containing a list of coords.

  • delimiter (ColumnOrName) – Delimiter that separates each coordinate in the coords column, a string constant must be wrapped as a string literal (using pyspark.sql.functions.lit).

Returns:

Linestring geometry column generated from the list of coordinates.

Return type:

Column

sedona.spark.sql.st_constructors.ST_LinestringFromWKB(wkb: Column | ConnectColumn | str, srid: Column | ConnectColumn | str | float | int | None = None) Column[source]

Generate a Line geometry column from a Well-Known Binary (WKB) binary column.

Parameters:
  • wkb (ColumnOrName) – WKB binary column to generate from.

  • srid (ColumnOrNameOrNumber) – SRID to be set for the geometry.

Returns:

Geometry column representing the WKB binary.

Return type:

Column

sedona.spark.sql.st_constructors.ST_MLineFromText(wkt: Column | ConnectColumn | str, srid: Column | ConnectColumn | str | float | int | None = None) Column[source]

Generate multiLineString geometry from a multiLineString WKT representation.

Parameters:

wkt (ColumnOrName) – multiLineString WKT string column to generate from.

Returns:

multiLineString geometry generated from the wkt column.

Return type:

Column

sedona.spark.sql.st_constructors.ST_MPointFromText(wkt: Column | ConnectColumn | str, srid: Column | ConnectColumn | str | float | int | None = None) Column[source]

Generate MultiPoint geometry from a MultiPoint WKT representation.

Parameters:
  • wkt (ColumnOrName) – MultiPoint WKT string column to generate from.

  • srid (ColumnOrNameOrNumber) – SRID for the geometry

Returns:

MultiPoint geometry generated from the wkt column.

Return type:

Column

sedona.spark.sql.st_constructors.ST_MPolyFromText(wkt: Column | ConnectColumn | str, srid: Column | ConnectColumn | str | float | int | None = None) Column[source]

Generate multiPolygon geometry from a multiPolygon WKT representation.

Parameters:

wkt (ColumnOrName) – multiPolygon WKT string column to generate from.

Returns:

multiPolygon geometry generated from the wkt column.

Return type:

Column

sedona.spark.sql.st_constructors.ST_MakeEnvelope(min_x: Column | ConnectColumn | str | float | int, min_y: Column | ConnectColumn | str | float | int, max_x: Column | ConnectColumn | str | float | int, max_y: Column | ConnectColumn | str | float | int, srid: Column | ConnectColumn | str | float | int | None = None) Column[source]

Generate a polygon geometry column from the minimum and maximum coordinates of an envelope with an option to add SRID

Parameters:
  • min_x (ColumnOrNameOrNumber) – Minimum X coordinate for the envelope.

  • min_y (ColumnOrNameOrNumber) – Minimum Y coordinate for the envelope.

  • max_x (ColumnOrNameOrNumber) – Maximum X coordinate for the envelope.

  • max_y (ColumnOrNameOrNumber) – Maximum Y coordinate for the envelope.

  • srid (ColumnOrNameOrNumber) – SRID to be set for the envelope.

Returns:

Polygon geometry column representing the envelope described by the coordinate bounds.

Return type:

Column

sedona.spark.sql.st_constructors.ST_MakePoint(x: Column | ConnectColumn | str | float | int, y: Column | ConnectColumn | str | float | int, z: Column | ConnectColumn | str | float | int | None = None, m: Column | ConnectColumn | str | float | int | None = None) Column[source]

Generate a 2D, 3D Z or 4D ZM Point geometry. If z is None then a 2D point is generated. This function doesn’t support M coordinates for creating a 4D ZM Point in Dataframe API.

Parameters:
  • x (ColumnOrNameOrNumber) – Either a number or numeric column representing the X coordinate of a point.

  • y (ColumnOrNameOrNumber) – Either a number or numeric column representing the Y coordinate of a point.

  • z (ColumnOrNameOrNumber) – Either a number or numeric column representing the Z coordinate of a point, if None then a 2D point is generated, defaults to None

  • m (ColumnOrNameOrNumber) – Either a number or numeric column representing the M coordinate of a point, if None then a point without M coordinate is generated, defaults to None

Returns:

Point geometry column generated from the coordinate values.

Return type:

Column

sedona.spark.sql.st_constructors.ST_MakePointM(x: Column | ConnectColumn | str | float | int, y: Column | ConnectColumn | str | float | int, m: Column | ConnectColumn | str | float | int) Column[source]

Generate 3D M Point geometry.

Parameters:
  • x (ColumnOrNameOrNumber) – Either a number or numeric column representing the X coordinate of a point.

  • y (ColumnOrNameOrNumber) – Either a number or numeric column representing the Y coordinate of a point.

  • m (ColumnOrNameOrNumber) – Either a number or numeric column representing the M coordinate of a point

Returns:

Point geometry column generated from the coordinate values.

Return type:

Column

sedona.spark.sql.st_constructors.ST_Point(x: Column | ConnectColumn | str | float | int, y: Column | ConnectColumn | str | float | int) Column[source]

Generates a 2D point geometry column from numeric values.

Parameters:
  • x (ColumnOrNameOrNumber) – Either a number or numeric column representing the X coordinate of a point.

  • y (ColumnOrNameOrNumber) – Either a number or numeric column representing the Y coordinate of a point.

Returns:

Point geometry column generated from the coordinate values.

Return type:

Column

sedona.spark.sql.st_constructors.ST_PointFromGeoHash(geohash: Column | ConnectColumn | str, precision: Column | ConnectColumn | str | int | None = None) Column[source]

Generate a point column from a geohash column at a specified precision.

Parameters:
  • geohash (ColumnOrName) – Geohash string column to generate from.

  • precision (Union[ColumnOrName, int]) – Geohash precision to use, either an integer or an integer column.

Returns:

Point column representing the supplied geohash and precision level.

Return type:

Column

sedona.spark.sql.st_constructors.ST_PointFromText(coords: Column | ConnectColumn | str, delimiter: Column | ConnectColumn | str) Column[source]

Generate a point geometry column from coordinates separated by a delimiter and stored in a string column.

Parameters:
  • coords (ColumnOrName) – String column with the stored coordinates.

  • delimiter (ColumnOrName) – Delimiter separating the coordinates, a string constant must be wrapped as a string literal (using pyspark.sql.functions.lit).

Returns:

Point geometry column generated from the coordinates.

Return type:

Column

sedona.spark.sql.st_constructors.ST_PointFromWKB(wkb: Column | ConnectColumn | str, srid: Column | ConnectColumn | str | float | int | None = None) Column[source]

Generate a Point geometry column from a Well-Known Binary (WKB) binary column.

Parameters:
  • wkb (ColumnOrName) – WKB binary column to generate from.

  • srid (ColumnOrNameOrNumber) – SRID to be set for geometry

Returns:

Point Geometry column representing the WKB binary.

Return type:

Column

sedona.spark.sql.st_constructors.ST_PointM(x: Column | ConnectColumn | str | float | int, y: Column | ConnectColumn | str | float | int, m: Column | ConnectColumn | str | float | int, srid: Column | ConnectColumn | str | float | int | None = None) Column[source]

Generates a 3D point geometry column from numeric values.

Parameters:
  • x (ColumnOrNameOrNumber) – Either a number or numeric column representing the X coordinate of a point.

  • y (ColumnOrNameOrNumber) – Either a number or numeric column representing the Y coordinate of a point.

  • z (ColumnOrNameOrNumber) – Either a number or numeric column representing the Z coordinate of a point, if None then a 2D point is generated, defaults to None

  • srid (Optional[ColumnOrNameOrNumber], optional) – The srid of the point. Defaults to 0 (unknown).

Returns:

Point geometry column generated from the coordinate values.

Return type:

Column

sedona.spark.sql.st_constructors.ST_PointZ(x: Column | ConnectColumn | str | float | int, y: Column | ConnectColumn | str | float | int, z: Column | ConnectColumn | str | float | int, srid: Column | ConnectColumn | str | float | int | None = None) Column[source]

Generates a 3D point geometry column from numeric values.

Parameters:
  • x (ColumnOrNameOrNumber) – Either a number or numeric column representing the X coordinate of a point.

  • y (ColumnOrNameOrNumber) – Either a number or numeric column representing the Y coordinate of a point.

  • z (ColumnOrNameOrNumber) – Either a number or numeric column representing the Z coordinate of a point, if None then a 2D point is generated, defaults to None

  • srid (Optional[ColumnOrNameOrNumber], optional) – The srid of the point. Defaults to 0 (unknown).

Returns:

Point geometry column generated from the coordinate values.

Return type:

Column

sedona.spark.sql.st_constructors.ST_PointZM(x: Column | ConnectColumn | str | float | int, y: Column | ConnectColumn | str | float | int, z: Column | ConnectColumn | str | float | int, m: Column | ConnectColumn | str | float | int, srid: Column | ConnectColumn | str | float | int | None = None) Column[source]

Generates a 3D point geometry column from numeric values.

Parameters:
  • x (ColumnOrNameOrNumber) – Either a number or numeric column representing the X coordinate of a point.

  • y (ColumnOrNameOrNumber) – Either a number or numeric column representing the Y coordinate of a point.

  • z (ColumnOrNameOrNumber) – Either a number or numeric column representing the Z coordinate of a point, if None then a 2D point is generated, defaults to None

  • m (ColumnOrNameOrNumber) – Either a number or numeric column representing the M value of a point.

  • srid (Optional[ColumnOrNameOrNumber], optional) – The srid of the point. Defaults to 0 (unknown).

Returns:

Point geometry column generated from the coordinate values.

Return type:

Column

sedona.spark.sql.st_constructors.ST_PolygonFromEnvelope(min_x: Column | ConnectColumn | str | float | int, min_y: Column | ConnectColumn | str | float | int, max_x: Column | ConnectColumn | str | float | int, max_y: Column | ConnectColumn | str | float | int) Column[source]

Generate a polygon geometry column from the minimum and maximum coordinates of an envelope.

Parameters:
  • min_x (ColumnOrNameOrNumber) – Minimum X coordinate for the envelope.

  • min_y (ColumnOrNameOrNumber) – Minimum Y coordinate for the envelope.

  • max_x (ColumnOrNameOrNumber) – Maximum X coordinate for the envelope.

  • max_y (ColumnOrNameOrNumber) – Maximum Y coordinate for the envelope.

Returns:

Polygon geometry column representing the envelope described by the coordinate bounds.

Return type:

Column

sedona.spark.sql.st_constructors.ST_PolygonFromText(coords: Column | ConnectColumn | str, delimiter: Column | ConnectColumn | str) Column[source]

Generate a polygon from a list of coordinates separated by a delimiter stored in a string column.

Parameters:
  • coords (ColumnOrName) – String column containing the coordinates.

  • delimiter (ColumnOrName) – Delimiter separating the coordinates, a string constant must be wrapped as a string literal (using pyspark.sql.functions.lit).

Returns:

Polygon geometry column generated from the list of coordinates.

Return type:

Column

sedona.spark.sql.st_functions module

sedona.spark.sql.st_functions.ExpandAddress(address: Column | ConnectColumn | str)[source]

Normalize an address string into its canonical forms.

Parameters:

address – The address string or column to normalize.

Returns:

An array of normalized address strings.

sedona.spark.sql.st_functions.GeometryType(geometry: Column | ConnectColumn | str)[source]

Return the type of the geometry as a string. This function also indicates if the geometry is measured, by returning a string of the form ‘POINTM’.

Parameters:

geometry (ColumnOrName) – Geometry column to calculate the dimension for.

Returns:

Type of geometry as a string column.

Return type:

Column

sedona.spark.sql.st_functions.ParseAddress(address: Column | ConnectColumn | str)[source]

Parse an address string into its components (label/value pairs).

Parameters:

address – The address string or column to parse.

Returns:

An array of maps with label/value pairs for address components.

sedona.spark.sql.st_functions.ST_3DDistance(a: Column | ConnectColumn | str, b: Column | ConnectColumn | str) Column[source]

Calculate the 3-dimensional minimum Cartesian distance between two geometry columns.

Parameters:
  • a (ColumnOrName) – One geometry column to use in the calculation.

  • b (ColumnOrName) – Other geometry column to use in the calculation.

Returns:

Minimum cartesian distance between a and b as a double column.

Return type:

Column

sedona.spark.sql.st_functions.ST_AddMeasure(geom: Column | ConnectColumn | str, measureStart: Column | ConnectColumn | str | float, measureEnd: Column | ConnectColumn | str | float) Column[source]

Interpolate measure values with the provided start and end points and return the result geometry.

Parameters:
  • geom (ColumnOrName) – Geometry column to use in the calculation.

  • measureStart (ColumnOrName) – Start point for the measure.

  • measureEnd (ColumnOrName) – End point for the measure.

Returns:

Result geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_AddPoint(line_string: Column | ConnectColumn | str, point: Column | ConnectColumn | str, index: Column | ConnectColumn | str | int | None = None) Column[source]

Add a point to either the end of a linestring or a specified index. If index is not provided then point will be added to the end of line_string.

Parameters:
  • line_string (ColumnOrName) – Linestring geometry column to add point to.

  • point (ColumnOrName) – Point geometry column to add to line_string.

  • index (Optional[Union[ColumnOrName, int]], optional) – 0-based index to insert point at in line_string, if None then point is appended to the end of line_string, defaults to None

Returns:

Linestring geometry column with point added.

Return type:

Column

sedona.spark.sql.st_functions.ST_Affine(geometry: Column | ConnectColumn | str, a: Column | ConnectColumn | str | float, b: Column | ConnectColumn | str | float, d: Column | ConnectColumn | str | float, e: Column | ConnectColumn | str | float, xOff: Column | ConnectColumn | str | float, yOff: Column | ConnectColumn | str | float, c: Column | ConnectColumn | str | float | None = None, f: Column | ConnectColumn | str | float | None = None, g: Column | ConnectColumn | str | float | None = None, h: Column | ConnectColumn | str | float | None = None, i: Column | ConnectColumn | str | float | None = None, zOff: Column | ConnectColumn | str | float | None = None) Column[source]

Apply a 3D/2D affine transformation to the given geometry x = a * x + b * y + c * z + xOff | x = a * x + b * y + xOff y = d * x + e * y + f * z + yOff | y = d * x + e * y + yOff z = g * x + h * y + i * z + zOff :param geometry: Geometry to apply affine transformation to :param a: :param b: :param c: Default 0.0 :param d: :param e: :param f: Default 0.0 :param g: Default 0.0 :param h: Default 0.0 :param i: Default 0.0 :param xOff: :param yOff: :param zOff: Default 0.0 :return: Geometry with affine transformation applied

sedona.spark.sql.st_functions.ST_Angle(g1: Column | ConnectColumn | str, g2: Column | ConnectColumn | str, g3: Column | ConnectColumn | str | None = None, g4: Column | ConnectColumn | str | None = None) Column[source]

Returns the computed angle between vectors formed by given geometries in radian. Range of result is between 0 and 2 * pi.

3 Variants:

  • Angle(Point1, Point2, Point3, Point4)

    Computes angle formed by vectors formed by Point1-Point2 and Point3-Point4

  • Angle(Point1, Point2, Point3)

    Computes angle formed by angle Point1-Point2-Point3

  • Angle(Line1, Line2)

    Computes angle between vectors formed by S1-E1 and S2-E2, where S and E are start and endpoints.

Parameters:
  • g1 – Point or Line

  • g2 – Point or Line

  • g3 – Point or None

  • g4 – Point or None

Returns:

Returns the computed angle

sedona.spark.sql.st_functions.ST_Area(geometry: Column | ConnectColumn | str) Column[source]

Calculate the area of a geometry.

Parameters:

geometry (ColumnOrName) – Geometry column to calculate the area of.

Returns:

Area of geometry as a double column.

Return type:

Column

sedona.spark.sql.st_functions.ST_AreaSpheroid(geometry: Column | ConnectColumn | str) Column[source]

Calculate the area of a geometry using WGS84 spheroid.

Parameters:

geometry (ColumnOrName) – Geometry column to calculate the area of.

Returns:

Area of geometry as a double column. Unit is meter.

Return type:

Column

sedona.spark.sql.st_functions.ST_AsBinary(geometry: Column | ConnectColumn | str) Column[source]

Generate the Well-Known Binary (WKB) representation of a geometry.

Parameters:

geometry (ColumnOrName) – Geometry column to generate WKB for.

Returns:

Well-Known Binary representation of geometry as a binary column.

Return type:

Column

sedona.spark.sql.st_functions.ST_AsEWKB(geometry: Column | ConnectColumn | str) Column[source]

Generate the Extended Well-Known Binary representation of a geometry. As opposed to WKB, EWKB will include the SRID of the geometry.

Parameters:

geometry (ColumnOrName) – Geometry to generate EWKB for.

Returns:

Extended Well-Known Binary representation of geometry as a binary column.

Return type:

Column

sedona.spark.sql.st_functions.ST_AsEWKT(geometry: Column | ConnectColumn | str) Column[source]

Generate the Extended Well-Known Text representation of a geometry column. As opposed to WKT, EWKT will include the SRID of the geometry.

Parameters:

geometry (ColumnOrName) – Geometry column to generate EWKT for.

Returns:

Extended Well-Known Text representation of geometry as a string column.

Return type:

Column

sedona.spark.sql.st_functions.ST_AsGML(geometry: Column | ConnectColumn | str) Column[source]

Generate the Geography Markup Language (GML) representation of a geometry column.

Parameters:

geometry (ColumnOrName) – Geometry column to generate GML for.

Returns:

GML representation of geometry as a string column.

Return type:

Column

sedona.spark.sql.st_functions.ST_AsGeoJSON(geometry: Column | ConnectColumn | str, type: Column | ConnectColumn | str | None = None) Column[source]

Generate the GeoJSON style representation of a geometry column.

Parameters:

geometry (ColumnOrName) – Geometry column to generate GeoJSON for.

Returns:

GeoJSON representation of geometry as a string column.

Return type:

Column

sedona.spark.sql.st_functions.ST_AsHEXEWKB(geometry: Column | ConnectColumn | str, endian: Column | ConnectColumn | str | None = None) Column[source]

Generate the Extended Well-Known Binary representation of a geometry as Hex string.

Parameters:

geometry (ColumnOrName) – Geometry to generate EWKB for.

Returns:

Extended Well-Known Binary representation of geometry as Hex string.

Return type:

Column

sedona.spark.sql.st_functions.ST_AsKML(geometry: Column | ConnectColumn | str) Column[source]

Generate the KML representation of a geometry column.

Parameters:

geometry (ColumnOrName) – Geometry column to generate KML for.

Returns:

KML representation of geometry as a string column.

Return type:

Column

sedona.spark.sql.st_functions.ST_AsText(geometry: Column | ConnectColumn | str) Column[source]

Generate the Well-Known Text (WKT) representation of a geometry column.

Parameters:

geometry (ColumnOrName) – Geometry column to generate WKT for.

Returns:

WKT representation of geometry as a string column.

Return type:

Column

sedona.spark.sql.st_functions.ST_Azimuth(point_a: Column | ConnectColumn | str, point_b: Column | ConnectColumn | str) Column[source]

Calculate the azimuth for two point columns in radians.

Parameters:
  • point_a (ColumnOrName) – One point geometry column to use for the calculation.

  • point_b (ColumnOrName) – Other point geometry column to use for the calculation.

Returns:

Azimuth for point_a and point_b in radians as a double column.

Return type:

Column

sedona.spark.sql.st_functions.ST_BestSRID(geometry: Column | ConnectColumn | str) Column[source]

Estimates the best SRID (EPSG code) of the geometry.

Parameters:

geometry (ColumnOrName) – Geometry column to calculate the boundary for.

Returns:

SRID as an Integer

Return type:

Column

sedona.spark.sql.st_functions.ST_BinaryDistanceBandColumn(geometry: Column | ConnectColumn | str, threshold: Column | ConnectColumn | str, include_zero_distance_neighbors: Column | ConnectColumn | str | bool = True, include_self: Column | ConnectColumn | str | bool = False, use_spheroid: Column | ConnectColumn | str | bool = False, attributes: Column | ConnectColumn | str = None) Column[source]

Creates a weights column containing the other records within the threshold and their weight.

Weights will always be 1.0.

@param geometry: name of the geometry column @param threshold: Distance threshold for considering neighbors @param include_zero_distance_neighbors: whether to include neighbors that are 0 distance. @param include_self: whether to include self in the list of neighbors @param use_spheroid: whether to use a cartesian or spheroidal distance calculation. Default is false @param attributes: the attributes to save in the neighbor column.

sedona.spark.sql.st_functions.ST_Boundary(geometry: Column | ConnectColumn | str) Column[source]

Calculate the closure of the combinatorial boundary of a geometry column.

Parameters:

geometry (ColumnOrName) – Geometry column to calculate the boundary for.

Returns:

Boundary of the input geometry as a geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_BoundingDiagonal(geometry: Column | ConnectColumn | str) Column[source]

Returns a LineString with the min/max values of each dimension of the bounding box of the given geometry as its start/end coordinates. :param geometry: Geometry to return bounding diagonal of. :return: LineString spanning min and max values of each dimension of the given geometry

sedona.spark.sql.st_functions.ST_Buffer(geometry: Column | ConnectColumn | str, buffer: Column | ConnectColumn | str | float | int, useSpheroid: Column | ConnectColumn | str | bool | None = False, parameters: Column | ConnectColumn | str | None = None) Column[source]

Calculate a geometry that represents all points whose distance from the input geometry column is equal to or less than a given amount.

Parameters:
  • geometry (ColumnOrName) – Input geometry column to buffer.

  • buffer (ColumnOrNameOrNumber) – Either a column or value for the amount to buffer the input geometry by.

Returns:

Buffered geometry as a geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_BuildArea(geometry: Column | ConnectColumn | str) Column[source]

Generate a geometry described by the constituent linework of the input geometry column.

Parameters:

geometry (ColumnOrName) – Linestring or multilinestring geometry column to use as input.

Returns:

Area formed by geometry as a geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_Centroid(geometry: Column | ConnectColumn | str) Column[source]

Calculate the centroid of the given geometry column.

Parameters:

geometry (ColumnOrName) – Geometry column to calculate a centroid for.

Returns:

Centroid of geometry as a point geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_ClosestPoint(a: Column | ConnectColumn | str, b: Column | ConnectColumn | str) Column[source]

Returns the 2-dimensional point on geom1 that is closest to geom2. This is the first point of the shortest line between the geometries.

Parameters:
  • a (ColumnOrName) – Geometry column to use in the calculation.

  • b (ColumnOrName) – Geometry column to use in the calculation.

Returns:

the 2-dimensional point on a that is closest to b.

Return type:

Column

sedona.spark.sql.st_functions.ST_Collect(*geometries: Column | ConnectColumn | str) Column[source]

Collect multiple geometry columns or an array of geometries into a single multi-geometry or geometry collection.

Parameters:

geometries – Either a single geometry column that holds an array of geometries or multiple geometry columns.

Returns:

If the types of geometries are homogeneous then a multi-geometry is returned, otherwise a geometry collection is returned.

Return type:

Column

sedona.spark.sql.st_functions.ST_CollectionExtract(collection: Column | ConnectColumn | str, geom_type: Column | ConnectColumn | str | int | None = None) Column[source]

Extract a specific type of geometry from a geometry collection column as a multi-geometry column.

Parameters:
  • collection (ColumnOrName) – Column for the geometry collection.

  • geom_type (Optional[Union[ColumnOrName, int]], optional) – Type of geometry to extract where 1 is point, 2 is linestring, and 3 is polygon, if None then the highest dimension geometry is extracted, defaults to None

Returns:

Multi-geometry column containing all geometry from collection of the selected type.

Return type:

Column

sedona.spark.sql.st_functions.ST_ConcaveHull(geometry: Column | ConnectColumn | str, pctConvex: Column | ConnectColumn | str | float, allowHoles: Column | ConnectColumn | str | bool | None = None) Column[source]

Generate the cancave hull of a geometry column.

Parameters:
  • geometry (ColumnOrName) – Geometry column to generate a cancave hull for.

  • pctConvex (Union[ColumnOrName, float]) – value between 0 and 1, controls the concaveness of the computed hull.

  • allowHoles (Optional[Union[ColumnOrName, bool]], optional) – The computed hull will not contain holes unless allowHoles is specified as true

Returns:

Concave hull of geometry as a geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_ConvexHull(geometry: Column | ConnectColumn | str) Column[source]

Generate the convex hull of a geometry column.

Parameters:

geometry (ColumnOrName) – Geometry column to generate a convex hull for.

Returns:

Convex hull of geometry as a geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_CoordDim(geometry: Column | ConnectColumn | str) Column[source]

Return the number of dimensions contained in a coordinate

Parameters:

geometry (ColumnOrName) – Geometry column to return for.

Returns:

Number of dimensions in a coordinate column as an integer column.

Return type:

Column

sedona.spark.sql.st_functions.ST_CrossesDateLine(a: Column | ConnectColumn | str) Column[source]

Check whether geometry a crosses the International Date Line.

Parameters:

a (ColumnOrName) – Geometry to check crossing with.

Returns:

True if geometry a cross the dateline.

Return type:

Column

sedona.spark.sql.st_functions.ST_DBSCAN(geometry: Column | ConnectColumn | str, epsilon: Column | ConnectColumn | str | float, min_pts: Column | ConnectColumn | str | int, use_spheroid: Column | ConnectColumn | str | bool | None = False) Column[source]

Perform DBSCAN clustering on the given geometry column.

@param geometry: Geometry column or name :type geometry: ColumnOrName @param epsilon: the distance between two points to be considered neighbors :type epsilon: ColumnOrName @param min_pts: the number of neighbors a point should have to form a cluster :type min_pts: ColumnOrName @param use_spheroid: whether to use spheroid for distance calculation :type use_spheroid: ColumnOrName @return: A struct indicating the cluster to which the point belongs and whether it is a core point

sedona.spark.sql.st_functions.ST_Degrees(angleInRadian: Column | ConnectColumn | str | float) Column[source]

Converts a given angle from radian to degrees :param angleInRadian: Angle in Radian :return: Angle in Degrees

sedona.spark.sql.st_functions.ST_DelaunayTriangles(geometry: Column | ConnectColumn | str, tolerance: Column | ConnectColumn | str | float | None = None, flag: Column | ConnectColumn | str | int | None = None) Column[source]

Computes the Delaunay Triangles of the vertices of the input geometry.

Parameters:
  • geometry (ColumnOrName) – Input geometry

  • tolerance (ColumnOrName or float)

  • flag (ColumnOrName or int) – Selects the output type

Returns:

Delaunay triangles of the input geometry

Return type:

ColumnOrName

sedona.spark.sql.st_functions.ST_Difference(a: Column | ConnectColumn | str, b: Column | ConnectColumn | str) Column[source]

Calculate the difference of two geometry columns. This difference is not symmetric. It only returns the part of geometry a that is not in b.

Parameters:
  • a (ColumnOrName) – Geometry column to use in the calculation.

  • b (ColumnOrName) – Geometry column to subtract from geometry column a.

Returns:

Part of geometry a that is not in b as a geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_Dimension(geometry: Column | ConnectColumn | str)[source]

Calculate the inherent dimension of a geometry column.

Parameters:

geometry (ColumnOrName) – Geometry column to calculate the dimension for.

Returns:

Dimension of geometry as an integer column.

Return type:

Column

sedona.spark.sql.st_functions.ST_Distance(a: Column | ConnectColumn | str, b: Column | ConnectColumn | str) Column[source]

Calculate the minimum cartesian distance between two geometry columns.

Parameters:
  • a (ColumnOrName) – Geometry column to use in the calculation.

  • b (ColumnOrName) – Other geometry column to use in the calculation.

Returns:

Two-dimensional cartesian distance between a and b as a double column.

Return type:

Column

sedona.spark.sql.st_functions.ST_DistanceSphere(a: Column | ConnectColumn | str, b: Column | ConnectColumn | str, radius: Column | ConnectColumn | str | float | None = 6371008.0) Column[source]

Calculate the haversine/great-circle distance between two geometry columns using a given radius.

Parameters:
  • a (ColumnOrName) – Geometry column to use in the calculation.

  • b (ColumnOrName) – Other geometry column to use in the calculation.

  • radius (Optional[Union[ColumnOrName, float]], optional) – Radius of the sphere, defaults to 6371008.0

Returns:

Two-dimensional haversine/great-circle distance between a and b as a double column. Unit is meter.

Return type:

Column

sedona.spark.sql.st_functions.ST_DistanceSpheroid(a: Column | ConnectColumn | str, b: Column | ConnectColumn | str) Column[source]

Calculate the geodesic distance between two geometry columns using WGS84 spheroid.

Parameters:
  • a (ColumnOrName) – Geometry column to use in the calculation.

  • b (ColumnOrName) – Other geometry column to use in the calculation.

Returns:

Two-dimensional geodesic distance between a and b as a double column. Unit is meter.

Return type:

Column

sedona.spark.sql.st_functions.ST_Dump(geometry: Column | ConnectColumn | str) Column[source]

Returns an array of geometries that are members of a multi-geometry or geometry collection column. If the input geometry is a regular geometry then the geometry is returned inside of a single element array.

Parameters:

geometry (ColumnOrName) – Geometry column to dump.

Returns:

Array of geometries column comprised of the members of geometry.

Return type:

Column

sedona.spark.sql.st_functions.ST_DumpPoints(geometry: Column | ConnectColumn | str) Column[source]

Return the list of points of a geometry column. Specifically, return the vertices of the input geometry as an array.

Parameters:

geometry (ColumnOrName) – Geometry column to dump the points of.

Returns:

Array of point geometry column comprised of the vertices of geometry.

Return type:

Column

sedona.spark.sql.st_functions.ST_EndPoint(line_string: Column | ConnectColumn | str) Column[source]

Return the last point of a linestring geometry column.

Parameters:

line_string (ColumnOrName) – Linestring geometry column to get the end point of.

Returns:

The last point of the linestring geometry column as a point geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_Envelope(geometry: Column | ConnectColumn | str) Column[source]

Calculate the envelope boundary of a geometry column.

Parameters:

geometry (ColumnOrName) – Geometry column to calculate the envelope of.

Returns:

Envelope of geometry as a geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_Expand(geometry: Column | ConnectColumn | str, deltaX_uniformDelta: Column | ConnectColumn | str | float, deltaY: Column | ConnectColumn | str | float | None = None, deltaZ: Column | ConnectColumn | str | float | None = None) Column[source]

Expand the given geometry column by a constant unit in each direction

Parameters:
  • geometry (ColumnOrName) – Geometry column to calculate the envelope of.

  • deltaX_uniformDelta (Union[ColumnOrName, float]) – it is either deltaX or uniformDelta depending on the number of arguments provided

  • deltaY (Union[ColumnOrName, float]) – Constant unit of deltaY

  • deltaZ (Union[ColumnOrName, float]) – Constant unit of deltaZ

Returns:

Envelope of geometry as a geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_ExteriorRing(polygon: Column | ConnectColumn | str) Column[source]

Get a linestring representing the exterior ring of a polygon geometry column.

Parameters:

polygon (ColumnOrName) – Polygon geometry column to get the exterior ring of.

Returns:

Exterior ring of polygon as a linestring geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_FlipCoordinates(geometry: Column | ConnectColumn | str) Column[source]

Flip the X and Y coordinates of a geometry column.

Parameters:

geometry (ColumnOrName) – Geometry column to flip coordinates for.

Returns:

Geometry column identical to geometry except with flipped coordinates.

Return type:

Column

sedona.spark.sql.st_functions.ST_Force2D(geometry: Column | ConnectColumn | str) Column[source]

Force the geometry column to only output two dimensional representations.

Parameters:

geometry (ColumnOrName) – Geometry column to force to be 2D.

Returns:

Geometry column identical to geometry except with only X and Y coordinates.

Return type:

Column

sedona.spark.sql.st_functions.ST_Force3D(geometry: Column | ConnectColumn | str, zValue: Column | ConnectColumn | str | float | None = 0.0) Column[source]

Return a geometry with a 3D coordinate of value ‘zValue’ forced upon it. No change happens if the geometry is already 3D :param zValue: Optional value of z coordinate to be potentially added, default value is 0.0 :param geometry: Geometry column to make 3D :return: 3D geometry with either already present z coordinate if any, or zcoordinate with given zValue

sedona.spark.sql.st_functions.ST_Force3DM(geometry: Column | ConnectColumn | str, mValue: Column | ConnectColumn | str | float | None = 0.0) Column[source]

Return a geometry with a 3D coordinate of value ‘mValue’ forced upon it. No change happens if the geometry is already 3D :param mValue: Optional value of m coordinate to be potentially added, default value is 0.0 :param geometry: Geometry column to make 3D :return: 3D geometry with either already present m coordinate if any, or m coordinate with given mValue

sedona.spark.sql.st_functions.ST_Force3DZ(geometry: Column | ConnectColumn | str, zValue: Column | ConnectColumn | str | float | None = 0.0) Column[source]

Return a geometry with a 3D coordinate of value ‘zValue’ forced upon it. No change happens if the geometry is already 3D :param zValue: Optional value of z coordinate to be potentially added, default value is 0.0 :param geometry: Geometry column to make 3D :return: 3D geometry with either already present z coordinate if any, or zcoordinate with given zValue

sedona.spark.sql.st_functions.ST_Force4D(geometry: Column | ConnectColumn | str, zValue: Column | ConnectColumn | str | float | None = 0.0, mValue: Column | ConnectColumn | str | float | None = 0.0) Column[source]

Return a geometry with a 4D coordinate of value ‘zValue’ and mValue forced upon it. No change happens if the geometry is already 4D, if geometry either has z or m, it will not change the existing z or m value.

Parameters:
  • zValue – Optional value of z coordinate to be potentially added, default value is 0.0

  • geometry – Geometry column to make 4D

Returns:

4D geometry with either already 4D geom or z and m component provided by zValue and mValue respectively

sedona.spark.sql.st_functions.ST_ForceCollection(geometry: Column | ConnectColumn | str) Column[source]

Converts a geometry to a geometry collection

Parameters:

geometry – Geometry column to change orientation

Returns:

a Geometry Collection

sedona.spark.sql.st_functions.ST_ForcePolygonCCW(geometry: Column | ConnectColumn | str) Column[source]

Returns a geometry with counter-clockwise oriented exterior ring and clockwise oriented interior rings :param geometry: Geometry column to change orientation :return: counter-clockwise oriented geometry

sedona.spark.sql.st_functions.ST_ForcePolygonCW(geometry: Column | ConnectColumn | str) Column[source]

Returns :param geometry: Geometry column to change orientation :return: Clockwise oriented geometry

sedona.spark.sql.st_functions.ST_ForceRHR(geometry: Column | ConnectColumn | str) Column[source]

Returns :param geometry: Geometry column to change orientation :return: Clockwise oriented geometry

sedona.spark.sql.st_functions.ST_Force_2D(geometry: Column | ConnectColumn | str) Column[source]

Force the geometry column to only output two dimensional representations.

Parameters:

geometry (ColumnOrName) – Geometry column to force to be 2D.

Returns:

Geometry column identical to geometry except with only X and Y coordinates.

Return type:

Column

sedona.spark.sql.st_functions.ST_FrechetDistance(g1: Column | ConnectColumn | str, g2: Column | ConnectColumn | str) Column[source]

Computes discrete frechet distance between the two geometries. If any of the geometry is empty, ST_FrechetDistance returns 0 :param g1: :param g2: :return: Computed Discrete Frechet Distance between g1 and g2

sedona.spark.sql.st_functions.ST_GLocal(x: Column | ConnectColumn | str, weights: Column | ConnectColumn | str, star: Column | ConnectColumn | str | bool | None = False) Column[source]

Calculate Getis Ord Gi(*) statistics on the given column.

@param x: The variable we want to compute Gi statistics for :type x: ColumnOrName @param weights: the weights array containing the neighbors, their weights, and their values of x :type weights: ColumnOrName @param star: whether to use the focal observation in the calculations :type star: ColumnOrName @return: A struct containing the Gi statistics including a p value

sedona.spark.sql.st_functions.ST_GeneratePoints(geometry: Column | ConnectColumn | str, numPoints: Column | ConnectColumn | str | int, seed: Column | ConnectColumn | str | int | None = None) Column[source]

Generate random points in given geometry.

Parameters:
  • geometry (ColumnOrName) – Geometry column to hash.

  • numPoints (Union[ColumnOrName, int]) – Precision level to hash geometry at, given as an integer or an integer column.

Returns:

Generate random points in given geometry

Return type:

Column

sedona.spark.sql.st_functions.ST_GeoHash(geometry: Column | ConnectColumn | str, precision: Column | ConnectColumn | str | int) Column[source]

Return the geohash of a geometry column at a given precision level.

Parameters:
  • geometry (ColumnOrName) – Geometry column to hash.

  • precision (Union[ColumnOrName, int]) – Precision level to hash geometry at, given as an integer or an integer column.

Returns:

Geohash of geometry as a string column.

Return type:

Column

sedona.spark.sql.st_functions.ST_GeometricMedian(geometry: Column | ConnectColumn | str, tolerance: Column | ConnectColumn | str | float | None = 1e-6, max_iter: Column | ConnectColumn | str | int | None = 1000, fail_if_not_converged: Column | ConnectColumn | str | bool | None = False) Column[source]

Computes the approximate geometric median of a MultiPoint geometry using the Weiszfeld algorithm. The geometric median provides a centrality measure that is less sensitive to outlier points than the centroid. The algorithm will iterate until the distance change between successive iterations is less than the supplied tolerance parameter. If this condition has not been met after maxIter iterations, the function will produce an error and exit, unless failIfNotConverged is set to false. If a tolerance value is not provided, a default tolerance value is 1e-6.

Parameters:
  • geometry (ColumnOrName) – MultiPoint or Point geometry.

  • tolerance (Optional[Union[ColumnOrName, float]], optional) – Distance limit change between successive iterations, defaults to 1e-6.

  • max_iter (Optional[Union[ColumnOrName, int]], optional) – Max number of iterations, defaults to 1000.

  • fail_if_not_converged (Optional[Union[ColumnOrName, boolean]], optional) – Generate error if not converged within given tolerance and number of iterations, defaults to False

Returns:

Point geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_GeometryN(multi_geometry: Column | ConnectColumn | str, n: Column | ConnectColumn | str | int) Column[source]

Return the geometry at index n (0-th based) of a multi-geometry column.

Parameters:
  • multi_geometry (ColumnOrName) – Multi-geometry column to get from.

  • n (Union[ColumnOrName, int]) – Index to select, given as an integer or integer column, 0-th based index, returns null if index is greater than maximum index.

Returns:

Geometry located at index n in multi_geometry as a geometry column.

Return type:

Column

Raises:

ValueError – If

sedona.spark.sql.st_functions.ST_GeometryType(geometry: Column | ConnectColumn | str) Column[source]

Return the type of geometry in a given geometry column.

Parameters:

geometry (ColumnOrName) – Geometry column to find the type for.

Returns:

Type of geometry as a string column.

Return type:

Column

sedona.spark.sql.st_functions.ST_H3CellDistance(cell1: Column | ConnectColumn | str | int, cell2: Column | ConnectColumn | str | int) Column[source]

Cover Geometry with H3 Cells and return a List of Long type cell IDs :param cell: start cell :type cell: long :param k: end cell :type k: int :return: distance between cells :rtype: Long

sedona.spark.sql.st_functions.ST_H3CellIDs(geometry: Column | ConnectColumn | str, level: Column | ConnectColumn | str | int, full_cover: Column | ConnectColumn | str | bool) Column[source]

Cover Geometry with H3 Cells and return a List of Long type cell IDs :param geometry: Geometry column to generate cell IDs :type geometry: ColumnOrName :param level: value between 1 and 15, controls the size of the cells used for coverage. With a bigger level, the cells will be smaller, the coverage will be more accurate, but the result size will be exponentially increasing. :type level: int :param full_cover: ColumnOrName :type full_cover: int :return: List of cellIDs :rtype: List[long]

sedona.spark.sql.st_functions.ST_H3KRing(cell: Column | ConnectColumn | str | int, k: Column | ConnectColumn | str | int, exact_ring: Column | ConnectColumn | str | bool) Column[source]

Cover Geometry with H3 Cells and return a List of Long type cell IDs :param cell: original cell :type cell: long :param k: the k number of rings spread from the original cell :type k: int :param exact_ring: if exactDistance is true, it will only return the cells on the exact kth ring, else will return all 0 - kth neighbors :type exact_ring: bool :return: List of cellIDs :rtype: List[long]

sedona.spark.sql.st_functions.ST_H3ToGeom(cells: Column | ConnectColumn | str | list) Column[source]

Cover Geometry with H3 Cells and return a List of Long type cell IDs :param cells: h3 cells :return: the reversed multipolygon :rtype: Geometry

sedona.spark.sql.st_functions.ST_HasM(geom: Column | ConnectColumn | str) Column[source]

Check whether geometry has M coordinate

Parameters:

geom (ColumnOrName) – Geometry

Returns:

True if geometry has M coordinate, else False

Return type:

Column

sedona.spark.sql.st_functions.ST_HasZ(geom: Column | ConnectColumn | str) Column[source]

Check whether geometry has Z coordinate

Parameters:

geom (ColumnOrName) – Geometry

Returns:

True if geometry has Z coordinate, else False

Return type:

Column

sedona.spark.sql.st_functions.ST_HausdorffDistance(g1: Column | ConnectColumn | str, g2: Column | ConnectColumn | str, densityFrac: Column | ConnectColumn | str | float | None = -1) Column[source]

Returns discretized (and hence approximate) hausdorff distance between two given geometries. Optionally, a distance fraction can also be provided which decreases the gap between actual and discretized hausforff distance :param g1: :param g2: :param densityFrac: Optional :return:

sedona.spark.sql.st_functions.ST_InteriorRingN(polygon: Column | ConnectColumn | str, n: Column | ConnectColumn | str | int) Column[source]

Return the index n (0-th based) interior ring of a polygon geometry column.

Parameters:
  • polygon (ColumnOrName) – Polygon geometry column to get an interior ring from.

  • n (Union[ColumnOrName, int]) – Index of interior ring to return as either an integer or integer column, 0-th based.

Raises:

ValueError – If n is an integer and less than 0.

Returns:

Interior ring at index n as a linestring geometry column or null if n is greater than maximum index

Return type:

Column

sedona.spark.sql.st_functions.ST_InterpolatePoint(geom1: Column | ConnectColumn | str, geom2: Column | ConnectColumn | str) Column[source]

Returns the interpolated Measure value at the point on the given linestring M that is closest to the given point.

Parameters:
  • geom1 (ColumnOrName) – LineString M Geometry column or name.

  • geom2 (ColumnOrName) – Point Geometry column or name.

Return type:

Column

sedona.spark.sql.st_functions.ST_Intersection(a: Column | ConnectColumn | str, b: Column | ConnectColumn | str) Column[source]

Calculate the intersection of two geometry columns.

Parameters:
  • a (ColumnOrName) – One geometry column to use in the calculation.

  • b (ColumnOrName) – Other geometry column to use in the calculation.

Returns:

Intersection of a and b as a geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_IsClosed(geometry: Column | ConnectColumn | str) Column[source]

Check if the linestring in a geometry column is closed (its end point is equal to its start point).

Parameters:

geometry (ColumnOrName) – Linestring geometry column to check.

Returns:

True if geometry is closed and False otherwise as a boolean column.

Return type:

Column

sedona.spark.sql.st_functions.ST_IsCollection(geometry: Column | ConnectColumn | str) Column[source]

Check if the geometry is of GeometryCollection type.

Parameters:

geometry (ColumnOrName) – Column for geometry collection

Returns:

True if geometry is a collection of geometries.

Return type:

Column

sedona.spark.sql.st_functions.ST_IsEmpty(geometry: Column | ConnectColumn | str) Column[source]

Check if the geometry in a geometry column is an empty geometry.

Parameters:

geometry (ColumnOrName) – Geometry column to check.

Returns:

True if the geometry is empty and False otherwise as a boolean column.

Return type:

Column

sedona.spark.sql.st_functions.ST_IsPolygonCCW(geometry: Column | ConnectColumn | str) Column[source]

Check if the Polygon or MultiPolygon use a counter-clockwise orientation for exterior ring and clockwise orientation for interior ring. :param geometry: Geometry column to check. :type geometry: ColumnOrName :return: True if the geometry is empty and False otherwise as a boolean column. :rtype: Column

sedona.spark.sql.st_functions.ST_IsPolygonCW(geometry: Column | ConnectColumn | str) Column[source]

Check if the Polygon or MultiPolygon use a clockwise orientation for exterior ring and counter-clockwise orientation for interior ring.

Parameters:

geometry (ColumnOrName) – Geometry column to check.

Returns:

True if the geometry is empty and False otherwise as a boolean column.

Return type:

Column

sedona.spark.sql.st_functions.ST_IsRing(line_string: Column | ConnectColumn | str) Column[source]

Check if a linestring geometry is both closed and simple.

Parameters:

line_string (ColumnOrName) – Linestring geometry column to check.

Returns:

True if the linestring is both closed and simple and False otherwise as a boolean column.

Return type:

Column

sedona.spark.sql.st_functions.ST_IsSimple(geometry: Column | ConnectColumn | str) Column[source]

Check if a geometry’s only intersections are at boundary points.

Parameters:

geometry (ColumnOrName) – Geometry column to check in.

Returns:

True if geometry is simple and False otherwise as a boolean column.

Return type:

Column

sedona.spark.sql.st_functions.ST_IsValid(geometry: Column | ConnectColumn | str, flag: Column | ConnectColumn | str | int | None = None) Column[source]

Check if a geometry is well formed.

Parameters:
  • geometry (ColumnOrName) – Geometry column to check in.

  • flag (Optional[Union[ColumnOrName, int]]) – Optional flag to modify behavior of the validity check.

Returns:

True if geometry is well formed and False otherwise as a boolean column.

Return type:

Column

sedona.spark.sql.st_functions.ST_IsValidDetail(geometry: Column | ConnectColumn | str, flag: Column | ConnectColumn | str | int | None = None) Column[source]

Return a row of valid, reason and location. valid defines the validity of geometry, reason defines the reason why it is not valid and location defines the location where it is not valid If the geometry is valid then it will return null for reason and location

Parameters:
  • geometry (ColumnOrName) – Geometry column to validate.

  • flag (Optional[Union[ColumnOrName, int]]) – Optional flag to modify behavior of the validity check.

Returns:

Row of valid, reason and location

Return type:

Column

sedona.spark.sql.st_functions.ST_IsValidReason(geometry: Column | ConnectColumn | str, flag: Column | ConnectColumn | str | int | None = None) Column[source]

Provides a text description of why a geometry is not valid or states that it is valid. An optional flag parameter can be provided for additional options.

Parameters:
  • geometry (ColumnOrName) – Geometry column to validate.

  • flag (Optional[Union[ColumnOrName, int]]) – Optional flag to modify behavior of the validity check.

Returns:

Description of validity as a string column.

Return type:

Column

sedona.spark.sql.st_functions.ST_IsValidTrajectory(geometry: Column | ConnectColumn | str) Column[source]

Tests if a geometry encodes a valid trajectory. A valid trajectory is represented as a LINESTRING with measures (M values). The measure values must increase from each vertex to the next.

Parameters:

geometry (ColumnOrName) – Geometry column to validate.

Returns:

True if the geometry is valid trajectory and False otherwise as a boolean column.

Return type:

Column

sedona.spark.sql.st_functions.ST_LabelPoint(geometry: Column | ConnectColumn | str, gridResolution: Column | ConnectColumn | str | float | int | None = None, goodnessThreshold: Column | ConnectColumn | str | float | int | None = None) Column[source]

Calculate an anchor point for a given geometry column.

Parameters:
  • geometry (ColumnOrName) – Input geometry column to calculate the anchor for.

  • gridResolution (Optional[Union[ColumnOrNameOrNumber, int]], optional) – Optional step size for grid search when determining the best anchor point. Defaults to 2 if not provided.

  • goodnessThreshold (Optional[Union[ColumnOrNameOrNumber, float]], optional) – Optional threshold for the minimum “goodness” value. Determines when to stop refining the anchor search. Defaults to 0.2 if not provided.

Returns:

Anchor point as a geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_Length(geometry: Column | ConnectColumn | str) Column[source]

Calculate the length of a linestring geometry.

Parameters:

geometry (ColumnOrName) – Linestring geometry column to calculate length for.

Returns:

Length of geometry as a double column.

Return type:

Column

sedona.spark.sql.st_functions.ST_Length2D(geometry: Column | ConnectColumn | str) Column[source]

Calculate the length of a linestring geometry.

Parameters:

geometry (ColumnOrName) – Linestring geometry column to calculate length for.

Returns:

Length of geometry as a double column.

Return type:

Column

sedona.spark.sql.st_functions.ST_LengthSpheroid(geometry: Column | ConnectColumn | str) Column[source]

Calculate the perimeter of a geometry using WGS84 spheroid.

Parameters:

geometry (ColumnOrName) – Geometry column to calculate length for.

Returns:

perimeter of geometry as a double column. Unit is meter.

Return type:

Column

sedona.spark.sql.st_functions.ST_LineFromMultiPoint(geometry: Column | ConnectColumn | str) Column[source]

Creates a LineString from a MultiPoint geometry.

Parameters:

geometry (ColumnOrName) – MultiPoint geometry column to create LineString from.

Returns:

LineString geometry of a MultiPoint geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_LineInterpolatePoint(geometry: Column | ConnectColumn | str, fraction: Column | ConnectColumn | str | float | int) Column[source]

Calculate a point that is interpolated along a linestring.

Parameters:
  • geometry (ColumnOrName) – Linestring geometry column to interpolate from.

  • fraction (ColumnOrNameOrNumber) – Fraction of total length along geometry to generate a point for.

Returns:

Interpolated point as a point geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_LineLocatePoint(linestring: Column | ConnectColumn | str, point: Column | ConnectColumn | str) Column[source]

Returns a double between 0 and 1 representing the location of the closest point on a LineString to the given Point, as a fraction of 2d line length.

Parameters:
  • linestring – Linestring geometry column to locate point on.

  • point – Point geometry column.

Returns:

double between 0 and 1 as a fraction of 2d line length.

Return type:

Column

sedona.spark.sql.st_functions.ST_LineMerge(multi_line_string: Column | ConnectColumn | str) Column[source]

Sew together the constituent line work of a multilinestring into a single linestring.

Parameters:

multi_line_string (ColumnOrName) – Multilinestring geometry column to merge.

Returns:

Linestring geometry column resulting from the merger of multi_line_string.

Return type:

Column

sedona.spark.sql.st_functions.ST_LineSegments(geom: Column | ConnectColumn | str, lenient: Column | ConnectColumn | str | bool | None = None) Column[source]

Convert multi-coordinate LineString into an array of LineStrings that contain exactly 2 points.

@param geom: input LineString geometry column. @param lenient: suppresses exception @return: array of LineStrings

sedona.spark.sql.st_functions.ST_LineSubstring(line_string: Column | ConnectColumn | str, start_fraction: Column | ConnectColumn | str | float | int, end_fraction: Column | ConnectColumn | str | float | int) Column[source]

Generate a substring of a linestring geometry column.

Parameters:
  • line_string (ColumnOrName) – Linestring geometry column to generate from.

  • start_fraction (ColumnOrNameOrNumber) – Fraction of linestring to start from for the resulting substring as either a number or numeric column.

  • end_fraction (ColumnOrNameOrNumber) – Fraction of linestring to end at for the resulting substring as either a number or numeric column.

Returns:

Smaller linestring that runs from start_fraction to end_fraction of line_string as a linestring geometry column, will be null if either start_fraction or end_fraction are outside the interval [0, 1].

Return type:

Column

sedona.spark.sql.st_functions.ST_LocalOutlierFactor(geometry: Column | ConnectColumn | str, k: Column | ConnectColumn | str | int, use_spheroid: Column | ConnectColumn | str | bool | None = False) Column[source]

Calculate the local outlier factor on the given geometry column.

@param geometry: Geometry column or name :type geometry: ColumnOrName @param k: the number of neighbors to use for LOF calculation :type k: ColumnOrName @param use_spheroid: whether to use spheroid for distance calculation :type use_spheroid: ColumnOrName @return: A Double indicating the local outlier factor of the point

sedona.spark.sql.st_functions.ST_LocateAlong(geom: Column | ConnectColumn | str, measure: Column | ConnectColumn | str | float, offset: Column | ConnectColumn | str | float | None = None) Column[source]

return locations along a measure geometry that have the given measure value.

Parameters:
  • geom (ColumnOrName)

  • measure (Union[ColumnOrName, float])

  • offset (Union[ColumnOrNameOrNumber, float])

Returns:

Locations along a measure geometry that have the given measure value.

Return type:

Column

sedona.spark.sql.st_functions.ST_LongestLine(geom1: Column | ConnectColumn | str, geom2: Column | ConnectColumn | str) Column[source]

Compute the longest line between the two geometries

Parameters:
  • geom1 (ColumnOrName)

  • geom2 (ColumnOrName)

Returns:

Longest line between the two input geometries

Return type:

Column

sedona.spark.sql.st_functions.ST_M(geom: Column | ConnectColumn | str) Column[source]

Return the M coordinate of a point geometry.

Parameters:

point (ColumnOrName) – Point geometry column to get the coordinate for.

Returns:

M coordinate of the point geometry as a double column.

Return type:

Column

sedona.spark.sql.st_functions.ST_MMax(geom: Column | ConnectColumn | str) Column[source]

Return the maximum M coordinate of a geometry.

Parameters:

geometry (ColumnOrName) – Geometry column to get the maximum M coordinate from.

Returns:

Minimum M coordinate for the geometry as a double column.

Return type:

Column

sedona.spark.sql.st_functions.ST_MMin(geom: Column | ConnectColumn | str) Column[source]

Return the minimum M coordinate of a geometry.

Parameters:

geometry (ColumnOrName) – Geometry column to get the minimum M coordinate from.

Returns:

Minimum M coordinate for the geometry as a double column.

Return type:

Column

sedona.spark.sql.st_functions.ST_MakeLine(geom1: Column | ConnectColumn | str, geom2: Column | ConnectColumn | str | None = None) Column[source]

Creates a LineString containing the points of Point, MultiPoint, or LineString geometries. Other geometry types cause an error.

Parameters:
  • geom1 – Geometry column to convert.

  • geom2 – Geometry column to convert. If geoms is empty, then geom1 is an array of geometries.

Returns:

LineString geometry column created from the input geometries.

Return type:

Column

sedona.spark.sql.st_functions.ST_MakePolygon(line_string: Column | ConnectColumn | str, holes: Column | ConnectColumn | str | None = None) Column[source]

Create a polygon geometry from a linestring describing the exterior ring as well as an array of linestrings describing holes.

Parameters:
  • line_string (ColumnOrName) – Closed linestring geometry column that describes the exterior ring of the polygon.

  • holes (Optional[ColumnOrName], optional) – Optional column for an array of closed geometry columns that describe holes in the polygon, defaults to None.

Returns:

Polygon geometry column created from the input linestrings.

Return type:

Column

sedona.spark.sql.st_functions.ST_MakeValid(geometry: Column | ConnectColumn | str, keep_collapsed: Column | ConnectColumn | str | bool | None = None) Column[source]

Convert an invalid geometry in a geometry column into a valid geometry.

Parameters:
  • geometry (ColumnOrName) – Geometry column that contains the invalid geometry.

  • keep_collapsed (Optional[Union[ColumnOrName, bool]], optional) – If True then collapsed geometries are converted to empty geometries, otherwise they will be converted to valid geometries of a lower dimension, if None then the default value of False is used, defaults to None

Returns:

Geometry column that contains valid versions of the original geometry.

Return type:

Column

sedona.spark.sql.st_functions.ST_MaxDistance(geom1: Column | ConnectColumn | str, geom2: Column | ConnectColumn | str) Column[source]

Calculate the maximum distance between two furthest points in the geometries

Parameters:
  • geom1 (ColumnOrName)

  • geom2 (ColumnOrName)

Returns:

Maximum distance between the geometries

Return type:

Column

sedona.spark.sql.st_functions.ST_MaximumInscribedCircle(geometry: Column | ConnectColumn | str) Column[source]

Finds the largest circle that is contained within a geometry, or which does not overlap any lines and points

Parameters:

geometry (ColumnOrName)

Returns:

Row of center point, nearest point and radius

Return type:

Column

sedona.spark.sql.st_functions.ST_MinimumBoundingCircle(geometry: Column | ConnectColumn | str, quadrant_segments: Column | ConnectColumn | str | int | None = None) Column[source]

Generate the minimum bounding circle that contains a geometry.

Parameters:
  • geometry (ColumnOrName) – Geometry column to generate minimum bounding circles for.

  • quadrant_segments (Optional[Union[ColumnOrName, int]], optional) – Number of quadrant segments to use, if None then use a default value, defaults to None

Returns:

Geometry column that contains the minimum bounding circles.

Return type:

Column

sedona.spark.sql.st_functions.ST_MinimumBoundingRadius(geometry: Column | ConnectColumn | str) Column[source]

Calculate the minimum bounding radius from the centroid of a geometry that will contain it.

Parameters:

geometry (ColumnOrName) – Geometry column to generate minimum bounding radii for.

Returns:

Struct column with a center field containing point geometry for the center of geometry and a radius field with a double value for the bounding radius.

Return type:

Column

sedona.spark.sql.st_functions.ST_MinimumClearance(geometry: Column | ConnectColumn | str) Column[source]

Calculate the minimum clearance between two vertices

Parameters:

geometry (ColumnOrName) – Geometry column

Returns:

Minimum Clearance between the geometries

Return type:

Column

sedona.spark.sql.st_functions.ST_MinimumClearanceLine(geometry: Column | ConnectColumn | str) Column[source]

Calculate the minimum clearance Linestring between two vertices

Parameters:

geometry (ColumnOrName) – Geometry column

Returns:

Minimum Clearance Linestring between the geometries

Return type:

Column

sedona.spark.sql.st_functions.ST_Multi(geometry: Column | ConnectColumn | str) Column[source]

Convert the geometry column into a multi-geometry column.

Parameters:

geometry (ColumnOrName) – Geometry column to convert.

Returns:

Multi-geometry form of geometry as a geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_NDims(geometry: Column | ConnectColumn | str) Column[source]

Return the number of dimensions contained in a geometry.

Parameters:

geometry (ColumnOrName) – Geometry column to return for.

Returns:

Number of dimensions in a geometry column as an integer column.

Return type:

Column

sedona.spark.sql.st_functions.ST_NPoints(geometry: Column | ConnectColumn | str) Column[source]

Return the number of points contained in a geometry.

Parameters:

geometry (ColumnOrName) – Geometry column to return for.

Returns:

Number of points in a geometry column as an integer column.

Return type:

Column

sedona.spark.sql.st_functions.ST_NRings(geometry: Column | ConnectColumn | str) Column[source]

Returns the total number of rings in a Polygon or MultiPolygon. Compared to ST_NumInteriorRings, ST_NRings takes exterior rings into account as well. :param geometry: Geometry column to calculate rings for :return: Number of exterior rings + interior rings (if any) for the given Polygon or MultiPolygon

sedona.spark.sql.st_functions.ST_Normalize(geometry: Column | ConnectColumn | str) Column[source]

Convert geometry in a geometry column to a canonical form.

Parameters:

geometry (ColumnOrName) – Geometry to convert.

Returns:

Geometry with points ordered in a canonical way as a geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_NumGeometries(geometry: Column | ConnectColumn | str) Column[source]

Return the number of geometries contained in a multi-geometry.

Parameters:

geometry (ColumnOrName) – Multi-geometry column to return for.

Returns:

Number of geometries contained in a multi-geometry column as an integer column.

Return type:

Column

sedona.spark.sql.st_functions.ST_NumInteriorRing(geometry: Column | ConnectColumn | str) Column[source]

Return the number of interior rings contained in a polygon geometry.

Parameters:

geometry (ColumnOrName) – Polygon geometry column to return for.

Returns:

Number of interior rings polygons contain as an integer column.

Return type:

Column

sedona.spark.sql.st_functions.ST_NumInteriorRings(geometry: Column | ConnectColumn | str) Column[source]

Return the number of interior rings contained in a polygon geometry.

Parameters:

geometry (ColumnOrName) – Polygon geometry column to return for.

Returns:

Number of interior rings polygons contain as an integer column.

Return type:

Column

sedona.spark.sql.st_functions.ST_NumPoints(geometry: Column | ConnectColumn | str) Column[source]

Return the number of points in a LineString :param geometry: Geometry column to get number of points from. :type geometry: ColumnOrName :return: Number of points in a LineString as an integer column :rtype: Column

sedona.spark.sql.st_functions.ST_Perimeter(geom: Column | ConnectColumn | str, use_spheroid: Column | ConnectColumn | str | bool | None = None, lenient: Column | ConnectColumn | str | bool | None = None) Column[source]

Returns the perimeter of a Polygon/MultiPolygon geometries. Otherwise, returns 0

@param geom: Polygonal geometry @param use_spheroid: Use Spheroid @param lenient: suppresses the exception @return: Perimeter of a Polygon/MultiPolygon geometries

sedona.spark.sql.st_functions.ST_Perimeter2D(geom: Column | ConnectColumn | str, use_spheroid: Column | ConnectColumn | str | bool | None = None, lenient: Column | ConnectColumn | str | bool | None = None) Column[source]

Returns the perimeter of a Polygon/MultiPolygon geometries. Otherwise, returns 0

@param geom: Polygonal geometry @param use_spheroid: Use Spheroid @param lenient: suppresses the exception @return: Perimeter of a Polygon/MultiPolygon geometries

sedona.spark.sql.st_functions.ST_PointN(geometry: Column | ConnectColumn | str, n: Column | ConnectColumn | str | int) Column[source]

Get the n-th point (starts at 1) for a geometry.

Parameters:
  • geometry (ColumnOrName) – Geometry column to get the point from.

  • n (Union[ColumnOrName, int]) – Index for the point to return, 1-based, negative values start from the end so -1 is the last point, values that are out of bounds return null.

Returns:

n-th point from the geometry as a point geometry column, or null if index is out of bounds.

Return type:

Column

sedona.spark.sql.st_functions.ST_PointOnSurface(geometry: Column | ConnectColumn | str) Column[source]

Get a point that is guaranteed to lie on the surface.

Parameters:

geometry (ColumnOrName) – Geometry column containing the Surface to get a point from.

Returns:

Point that lies on geometry as a point geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_Points(geometry: Column | ConnectColumn | str) Column[source]

Creates a MultiPoint geometry consisting of all the coordinates of the input geometry

Parameters:

geometry (ColumnOrName) – input geometry.

Returns:

Multipoint geometry

Return type:

Column

sedona.spark.sql.st_functions.ST_Polygon(line_string: Column | ConnectColumn | str, srid: Column | ConnectColumn | str | float | int) Column[source]

Create a polygon built from the given LineString and sets the spatial reference system from the srid.

Parameters:
  • line_string (ColumnOrName) – Closed linestring geometry column that describes the exterior ring of the polygon.

  • srid (ColumnOrNameOrNumber) – Spatial reference system identifier.

Returns:

Polygon geometry column created from the input linestring.

Return type:

Column

sedona.spark.sql.st_functions.ST_Polygonize(geometry: Column | ConnectColumn | str) Column[source]

Generates a GeometryCollection composed of polygons that are formed from the linework of a set of input geometries.

Parameters:

geometry (ColumnOrName) – input geometry of type GeometryCollection

Returns:

GeometryCollection geometry column created from the input geometry.

Return type:

Column

sedona.spark.sql.st_functions.ST_Project(geom: Column | ConnectColumn | str, distance: Column | ConnectColumn | str | float, azimuth: Column | ConnectColumn | str | float, lenient: Column | ConnectColumn | str | bool | None = None) Column[source]

Calculates a new point location given a starting point, distance, and direction (azimuth).

@param geom: @param distance: @param azimuth: @param lenient: @return:

sedona.spark.sql.st_functions.ST_ReducePrecision(geometry: Column | ConnectColumn | str, precision: Column | ConnectColumn | str | int) Column[source]

Reduce the precision of the coordinates in geometry to a specified number of decimal places.

Parameters:
  • geometry (ColumnOrName) – Geometry to reduce the precision of.

  • precision (Union[ColumnOrName, int]) – Number of decimal places to reduce the precision to as either an integer or integer column, 0 reduces precision to whole numbers.

Returns:

Geometry with precision reduced to the indicated number of decimal places as a geometry column, empty geometry if an invalid precision is passed.

Return type:

Column

sedona.spark.sql.st_functions.ST_RemovePoint(line_string: Column | ConnectColumn | str, index: Column | ConnectColumn | str | int) Column[source]

Remove the specified point (0-th based) for a linestring geometry column.

Parameters:
  • line_string (ColumnOrName) – Linestring geometry column to remove the point from.

  • index (Union[ColumnOrName, int]) – Index for the point to remove as either an integer or an integer column, 0-th based, negative numbers are ignored.

Returns:

Linestring geometry column with the specified point removed, or null if the index is out of bounds.

Return type:

Column

sedona.spark.sql.st_functions.ST_RemoveRepeatedPoints(geom: Column | ConnectColumn | str, tolerance: Column | ConnectColumn | str | float | None = None) Column[source]

Removes duplicate coordinates from a geometry, optionally removing those within a specified distance tolerance.

@param geom: Geometry with repeated points @type geom: ColumnOrName @param tolerance: Tolerance for removing nearby coordinates @type tolerance: Optional[Union[ColumnOrName, float]] @return:

sedona.spark.sql.st_functions.ST_Reverse(geometry: Column | ConnectColumn | str) Column[source]

Reverse the points for the geometry.

Parameters:

geometry (ColumnOrName) – Geometry column to reverse points for.

Returns:

Geometry with points in reverse order compared to the original.

Return type:

Column

sedona.spark.sql.st_functions.ST_Rotate(geometry: Column | ConnectColumn | str, angle: Column | ConnectColumn | str | float, originX: Column | ConnectColumn | str | float | None = None, originY: Column | ConnectColumn | str | float | None = None, pointOrigin: Column | ConnectColumn | str | None = None) Column[source]

Return a counter-clockwise rotated geometry along the specified origin.

Parameters:
  • geometry (ColumnOrName) – Geometry column or name.

  • angle (Union[ColumnOrName, float]) – Rotation angle in radians.

  • originX (Union[ColumnOrName, float]) – Optional x-coordinate of the origin.

  • originY (Union[ColumnOrName, float]) – Optional y-coordinate of the origin.

  • pointOrigin (ColumnOrName) – Optional origin point for rotation.

Returns:

Returns the rotated geometry.

Return type:

Column

sedona.spark.sql.st_functions.ST_RotateX(geometry: Column | ConnectColumn | str, angle: Column | ConnectColumn | str | float) Column[source]

Returns geometry rotated by the given angle in X axis

@param geometry: Geometry column or name :type geometry: ColumnOrName @param angle: Rotation angle in radians :type angle: float @return: X-axis rotated geometry

sedona.spark.sql.st_functions.ST_RotateY(geometry: Column | ConnectColumn | str, angle: Column | ConnectColumn | str | float) Column[source]

Returns geometry rotated by the given angle in Y axis

@param geometry: Geometry column or name :type geometry: ColumnOrName @param angle: Rotation angle in radians :type angle: float @return: Y-axis rotated geometry

sedona.spark.sql.st_functions.ST_S2CellIDs(geometry: Column | ConnectColumn | str, level: Column | ConnectColumn | str | int) Column[source]

Cover Geometry with S2 Cells and return a List of Long type cell IDs :param geometry: Geometry column to generate cell IDs :type geometry: ColumnOrName :param level: value between 1 and 31, controls the size of the cells used for coverage. With a bigger level, the cells will be smaller, the coverage will be more accurate, but the result size will be exponentially increasing. :type level: int :return: List of cellIDs :rtype: List[long]

sedona.spark.sql.st_functions.ST_S2ToGeom(cells: Column | ConnectColumn | str | list) Column[source]

Create a polygon from the S2 cells

Parameters:

cells (List[long]) – S2 cells

Returns:

the Polygon for all S2 cells

Return type:

Geometry

sedona.spark.sql.st_functions.ST_SRID(geometry: Column | ConnectColumn | str) Column[source]

Get the SRID of geometry.

Parameters:

geometry (ColumnOrName) – Geometry column to get SRID from.

Returns:

SRID of geometry in the geometry column as an integer column.

Return type:

Column

sedona.spark.sql.st_functions.ST_Scale(geometry: Column | ConnectColumn | str, scaleX: Column | ConnectColumn | str | float | int, scaleY: Column | ConnectColumn | str | float | int) Column[source]

Scale geometry with X and Y axis.

@param geometry: @param scaleX: @param scaleY: @return:

sedona.spark.sql.st_functions.ST_ScaleGeom(geometry: Column | ConnectColumn | str, factor: Column | ConnectColumn | str, origin: Column | ConnectColumn | str | None = None) Column[source]

Scale geometry with the corodinates of factor geometry

@param geometry: @param factor: @param origin: @return:

sedona.spark.sql.st_functions.ST_Segmentize(geometry: Column | ConnectColumn | str, maxSegmentLength: Column | ConnectColumn | str | float) Column[source]

Returns a modified geometry/geography having no segment longer than max_segment_length. Length is computed in 2D. Segments are always split into equal-length subsegments.

Parameters:
  • geometry – Geometry column to segmentize.

  • maxSegmentLength – Maximum segment length

Returns:

Column

sedona.spark.sql.st_functions.ST_SetPoint(line_string: Column | ConnectColumn | str, index: Column | ConnectColumn | str | int, point: Column | ConnectColumn | str) Column[source]

Replace a point in a linestring.

Parameters:
  • line_string (ColumnOrName) – Linestring geometry column which contains the point to be replaced.

  • index (Union[ColumnOrName, int]) – Index for the point to be replaced, 0-based, negative values start from the end so -1 is the last point.

  • point (ColumnOrName) – Point geometry column to be newly set.

Returns:

Linestring geometry column with the replaced point, or null if the index is out of bounds.

Return type:

Column

sedona.spark.sql.st_functions.ST_SetSRID(geometry: Column | ConnectColumn | str, srid: Column | ConnectColumn | str | int) Column[source]

Set the SRID for geometry.

Parameters:
  • geometry (ColumnOrName) – Geometry column to set SRID for.

  • srid (Union[ColumnOrName, int]) – SRID to set as either an integer or an integer column.

Returns:

Geometry column with SRID set to srid.

Return type:

Column

sedona.spark.sql.st_functions.ST_ShiftLongitude(geometry: Column | ConnectColumn | str) Column[source]

Shifts longitudes between -180..0 degrees to 180..360 degrees and vice versa.

Parameters:

geometry (ColumnOrName) – Geometry column.

Returns:

Shifted geometry

Return type:

Column

sedona.spark.sql.st_functions.ST_Simplify(geometry: Column | ConnectColumn | str, distance_tolerance: Column | ConnectColumn | str | float | int) Column[source]

Simplify a geometry using Douglas-Peucker algorithm within a specified tolerance while preserving topological relationships.

Parameters:
  • geometry (ColumnOrName) – Geometry column to simplify.

  • distance_tolerance (ColumnOrNameOrNumber) – Tolerance for merging points together to simplify the geometry as either a number or numeric column.

Returns:

Simplified geometry as a geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_SimplifyPolygonHull(geometry: Column | ConnectColumn | str, vertexFactor: Column | ConnectColumn | str | float | int, isOuter: Column | ConnectColumn | str | bool | None = None) Column[source]

Simplify a geometry using Visvalingam-Whyatt algorithm within a specified tolerance while preserving topological relationships.

Parameters:
  • geometry (ColumnOrName) – Geometry column to simplify.

  • vertexFactor (ColumnOrNameOrNumber) – Tolerance for merging points together to simplify the geometry as either a number or numeric column.

Returns:

Simplified geometry as a geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_SimplifyPreserveTopology(geometry: Column | ConnectColumn | str, distance_tolerance: Column | ConnectColumn | str | float | int) Column[source]

Simplify a geometry within a specified tolerance while preserving topological relationships.

Parameters:
  • geometry (ColumnOrName) – Geometry column to simplify.

  • distance_tolerance (ColumnOrNameOrNumber) – Tolerance for merging points together to simplify the geometry as either a number or numeric column.

Returns:

Simplified geometry as a geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_SimplifyVW(geometry: Column | ConnectColumn | str, distance_tolerance: Column | ConnectColumn | str | float | int) Column[source]

Simplify a geometry using Visvalingam-Whyatt algorithm within a specified tolerance while preserving topological relationships.

Parameters:
  • geometry (ColumnOrName) – Geometry column to simplify.

  • distance_tolerance (ColumnOrNameOrNumber) – Tolerance for merging points together to simplify the geometry as either a number or numeric column.

Returns:

Simplified geometry as a geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_Snap(input: Column | ConnectColumn | str, reference: Column | ConnectColumn | str, tolerance: Column | ConnectColumn | str | float | int) Column[source]

Snaps input Geometry to reference Geometry controlled by distance tolerance.

Parameters:
  • input – Geometry

  • reference – Geometry to snap to

  • tolerance – Distance to control snapping

Returns:

Snapped Geometry

sedona.spark.sql.st_functions.ST_Split(input: Column | ConnectColumn | str, blade: Column | ConnectColumn | str) Column[source]

Split input geometry by the blade geometry.

Parameters:
  • input (ColumnOrName) – One geometry column to use.

  • blade – Other geometry column to use.

Returns:

Multi-geometry representing the split of input by blade.

Return type:

Column

sedona.spark.sql.st_functions.ST_StartPoint(line_string: Column | ConnectColumn | str) Column[source]

Get the first point from a linestring.

Parameters:

line_string (ColumnOrName) – Linestring geometry column to get the first points for.

Returns:

First of the linestring geometry as a point geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_SubDivide(geometry: Column | ConnectColumn | str, max_vertices: Column | ConnectColumn | str | int) Column[source]

Subdivide a geometry into an array of geometries with at maximum number of vertices in each.

Parameters:
  • geometry (ColumnOrName) – Geometry column to subdivide.

  • max_vertices (Union[ColumnOrName, int]) – Maximum number of vertices to have in each subdivision.

Returns:

Array of geometries that represent the subdivision of the original geometry.

Return type:

Column

sedona.spark.sql.st_functions.ST_SubDivideExplode(geometry: Column | ConnectColumn | str, max_vertices: Column | ConnectColumn | str | int) Column[source]

Same as ST_SubDivide except also explode the generated array into multiple rows.

Parameters:
  • geometry (ColumnOrName) – Geometry column to subdivide.

  • max_vertices (Union[ColumnOrName, int]) – Maximum number of vertices to have in each subdivision.

Returns:

Individual geometries exploded from the returned array of ST_SubDivide.

Return type:

Column

sedona.spark.sql.st_functions.ST_SymDifference(a: Column | ConnectColumn | str, b: Column | ConnectColumn | str) Column[source]

Calculate the symmetric difference of two geometries (the regions that are only in one of them).

Parameters:
  • a (ColumnOrName) – One geometry column to use.

  • b (ColumnOrName) – Other geometry column to use.

Returns:

Geometry representing the symmetric difference of a and b as a geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_Transform(geometry: Column | ConnectColumn | str, source_crs: Column | ConnectColumn | str, target_crs: Column | ConnectColumn | str | None = None, disable_error: Column | ConnectColumn | str | bool | None = None) Column[source]

Convert a geometry from one coordinate system to another coordinate system.

Parameters:
  • geometry (ColumnOrName) – Geometry column to convert.

  • source_crs (ColumnOrName) – Original coordinate system for geometry as a string, a string constant must be wrapped as a string literal (using pyspark.sql.functions.lit).

  • target_crs (ColumnOrName) – Coordinate system geometry will be converted to as a string, a string constant must be wrapped as a string literal (using pyspark.sql.functions.lit).

  • disable_error (Optional[Union[ColumnOrName, bool]], optional) – Whether to disable the error “Bursa wolf parameters required”, defaults to None

Returns:

Geometry converted to the target coordinate system as an

Return type:

Column

sedona.spark.sql.st_functions.ST_Translate(geometry: Column | ConnectColumn | str, deltaX: Column | ConnectColumn | str | float, deltaY: Column | ConnectColumn | str | float, deltaZ: Column | ConnectColumn | str | float | None = 0.0) Column[source]

Returns the geometry with x, y and z (if present) coordinates offset by given deltaX, deltaY, and deltaZ values. :param geometry: Geometry column whose coordinates are to be translated. :param deltaX: value by which to offset X coordinate. :param deltaY: value by which to offset Y coordinate. :param deltaZ: value by which to offset Z coordinate (if present). :return: The input geometry with its coordinates translated.

sedona.spark.sql.st_functions.ST_TriangulatePolygon(geom: Column | ConnectColumn | str) Column[source]

Computes the constrained Delaunay triangulation of polygons. Holes and Multipolygons are supported.

Parameters:

geom (ColumnOrName) – (Multi)Polygon to be triangulated.

Returns:

Triangulated Polygon as GeometryCollection of Polygons

Return type:

Column

sedona.spark.sql.st_functions.ST_UnaryUnion(geom: Column | ConnectColumn | str) Column[source]

Calculate the unary union of a geometry

Parameters:

geom (ColumnOrName) – Geometry to do union

Returns:

Geometry representing the unary union of geom as a geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_Union(a: Column | ConnectColumn | str, b: Column | ConnectColumn | str | None = None) Column[source]

Calculate the union of two geometries.

Parameters:
  • a (ColumnOrName) – One geometry column to use.

  • b (ColumnOrName) – Other geometry column to use.

Returns:

Geometry representing the union of a and b as a geometry column.

Return type:

Column

sedona.spark.sql.st_functions.ST_VoronoiPolygons(geometry: Column | ConnectColumn | str, tolerance: Column | ConnectColumn | str | float | None = 0.0, extendTo: Column | ConnectColumn | str | None = None) Column[source]

ST_VoronoiPolygons computes a two-dimensional Voronoi diagram from the vertices of the supplied geometry. The result is a GeometryCollection of Polygons that covers an envelope larger than the extent of the input vertices. Returns null if input geometry is null. Returns an empty geometry collection if the input geometry contains only one vertex. Returns an empty geometry collection if the extend_to envelope has zero area. :param geometry: Geometry column whose coordinates are to be built from. :param tolerance: The distance within which vertices will be considered equivalent. Robustness of the algorithm can be improved by supplying a nonzero tolerance distance. (default = 0.0) :param extendTo: If a geometry is supplied as the “extend_to” parameter, the diagram will be extended to cover the envelope of the “extend_to” geometry, unless that envelope is smaller than the default envelope (default = NULL, default envelope is boundingbox of input geometry extended by about 50% in each direction). :return: The two-dimensional Voronoi diagram geometry.

sedona.spark.sql.st_functions.ST_WeightedDistanceBandColumn(geometry: Column | ConnectColumn | str, threshold: Column | ConnectColumn | str, alpha: Column | ConnectColumn | str | float, include_zero_distance_neighbors: Column | ConnectColumn | str | bool = True, include_self: Column | ConnectColumn | str | bool = False, self_weight: Column | ConnectColumn | str | float = 1.0, use_spheroid: Column | ConnectColumn | str | bool = False, attributes: Column | ConnectColumn | str = None) Column[source]

Creates a weights column containing the other records within the threshold and their weight.

Weights will be distance^alpha.

Parameters:
  • geometry – name of the geometry column

  • threshold – Distance threshold for considering neighbors

  • alpha – alpha to use for inverse distance weights. Computation is dist^alpha. Default is -1.0

  • include_zero_distance_neighbors – whether to include neighbors that are 0 distance. If 0 distance neighbors are included, values are infinity as per the floating point spec (divide by 0)

  • include_self – whether to include self in the list of neighbors

  • self_weight – the value to use for the self weight. Default is 1.0

  • use_spheroid – whether to use a cartesian or spheroidal distance calculation. Default is false

  • attributes – the attributes to save in the neighbor column.

sedona.spark.sql.st_functions.ST_X(point: Column | ConnectColumn | str) Column[source]

Return the X coordinate of a point geometry.

Parameters:

point (ColumnOrName) – Point geometry column to get the coordinate for.

Returns:

X coordinate of the point geometry as a double column.

Return type:

Column

sedona.spark.sql.st_functions.ST_XMax(geometry: Column | ConnectColumn | str) Column[source]

Calculate the maximum X coordinate for a geometry.

Parameters:

geometry (ColumnOrName) – Geometry column to get maximum X coordinate for.

Returns:

Maximum X coordinate for the geometry as a double column.

Return type:

Column

sedona.spark.sql.st_functions.ST_XMin(geometry: Column | ConnectColumn | str) Column[source]

Calculate the minimum X coordinate for a geometry.

Parameters:

geometry (ColumnOrName) – Geometry column to get minimum X coordinate for.

Returns:

Minimum X coordinate for the geometry as a double column.

Return type:

Column

sedona.spark.sql.st_functions.ST_Y(point: Column | ConnectColumn | str) Column[source]

Return the Y coordinate of a point geometry.

Parameters:

point (ColumnOrName) – Point geometry column to return the Y coordinate for.

Returns:

Y coordinate of the point geometry column as a double column.

Return type:

Column

sedona.spark.sql.st_functions.ST_YMax(geometry: Column | ConnectColumn | str) Column[source]

Calculate the maximum Y coordinate for a geometry.

Parameters:

geometry (ColumnOrName) – Geometry column to get the maximum Y coordinate for.

Returns:

Maximum Y coordinate for the geometry as a double column.

Return type:

Column

sedona.spark.sql.st_functions.ST_YMin(geometry: Column | ConnectColumn | str) Column[source]

Calculate the minimum Y coordinate for a geometry.

Parameters:

geometry (ColumnOrName) – Geometry column to get the minimum Y coordinate for.

Returns:

Minimum Y coordinate for the geometry as a double column.

Return type:

Column

sedona.spark.sql.st_functions.ST_Z(point: Column | ConnectColumn | str) Column[source]

Return the Z coordinate of a point geometry.

Parameters:

point (ColumnOrName) – Point geometry column to get the Z coordinate from.

Returns:

Z coordinate for the point geometry as a double column.

Return type:

Column

sedona.spark.sql.st_functions.ST_ZMax(geometry: Column | ConnectColumn | str) Column[source]

Return the maximum Z coordinate of a geometry.

Parameters:

geometry (ColumnOrName) – Geometry column to get the maximum Z coordinate from.

Returns:

Maximum Z coordinate for the geometry as a double column.

Return type:

Column

sedona.spark.sql.st_functions.ST_ZMin(geometry: Column | ConnectColumn | str) Column[source]

Return the minimum Z coordinate of a geometry.

Parameters:

geometry (ColumnOrName) – Geometry column to get the minimum Z coordinate from.

Returns:

Minimum Z coordinate for the geometry as a double column.

Return type:

Column

sedona.spark.sql.st_functions.ST_Zmflag(geom: Column | ConnectColumn | str) Column[source]
Return the code indicating the ZM coordinate dimension of a geometry

2D = 0, 3D-M = 1, 3D-Z = 2, 4D = 3

Parameters:

geom (ColumnOrName) – Geometry column

Returns:

Code for coordinate dimension of the geometry as an integer column.

Return type:

Column

sedona.spark.sql.st_predicates module

sedona.spark.sql.st_predicates.ST_Contains(a: Column | ConnectColumn | str, b: Column | ConnectColumn | str) Column[source]

Check whether geometry a contains geometry b.

Parameters:
  • a (ColumnOrName) – Geometry column to check containment for.

  • b (ColumnOrName) – Geometry column to check containment of.

Returns:

True if geometry a contains geometry b and False otherwise as a boolean column.

Return type:

Column

sedona.spark.sql.st_predicates.ST_CoveredBy(a: Column | ConnectColumn | str, b: Column | ConnectColumn | str) Column[source]

Check if geometry a is covered by geometry b.

Parameters:
  • a (ColumnOrName) – Geometry column to check.

  • b (ColumnOrName) – Geometry column to check.

Returns:

True if a is covered by b and False otherwise, as a boolean column.

Return type:

Column

sedona.spark.sql.st_predicates.ST_Covers(a: Column | ConnectColumn | str, b: Column | ConnectColumn | str) Column[source]

Check whether geometry a covers geometry b.

Parameters:
  • a (ColumnOrName) – Geometry column to check.

  • b (ColumnOrName) – Geometry column to check.

Returns:

True if a covers b and False otherwise, as a boolean column.

Return type:

Column

sedona.spark.sql.st_predicates.ST_Crosses(a: Column | ConnectColumn | str, b: Column | ConnectColumn | str) Column[source]

Check whether geometry a crosses geometry b.

Parameters:
  • a (ColumnOrName) – Geometry to check crossing with.

  • b (ColumnOrName) – Geometry to check crossing of.

Returns:

True if geometry a cross geometry b and False otherwise as a boolean column.

Return type:

Column

sedona.spark.sql.st_predicates.ST_DWithin(a: Column | ConnectColumn | str, b: Column | ConnectColumn | str, distance: Column | ConnectColumn | str | float, use_sphere: Column | ConnectColumn | str | bool | None = None)[source]

Check if geometry a is within ‘distance’ units of geometry b :param a: Geometry column to check :param b: Geometry column to check :param distance: distance units to check the within predicate :param use_sphere: whether to use spheroid distance or euclidean distance :return: True if a is within distance units of Geometry b

sedona.spark.sql.st_predicates.ST_Disjoint(a: Column | ConnectColumn | str, b: Column | ConnectColumn | str) Column[source]

Check whether two geometries are disjoint.

Parameters:
  • a (ColumnOrName) – One geometry column to check.

  • b (ColumnOrName) – Other geometry column to check.

Returns:

True if a and b are disjoint and False otherwise as a boolean column.

Return type:

Column

sedona.spark.sql.st_predicates.ST_Equals(a: Column | ConnectColumn | str, b: Column | ConnectColumn | str) Column[source]

Check whether two geometries are equal regardless of vertex ordering.

Parameters:
  • a (ColumnOrName) – One geometry column to check.

  • b (ColumnOrName) – Other geometry column to check.

Returns:

True if a and b are equal and False otherwise, as a boolean column.

Return type:

Column

sedona.spark.sql.st_predicates.ST_Intersects(a: Column | ConnectColumn | str, b: Column | ConnectColumn | str) Column[source]

Check whether two geometries intersect.

Parameters:
  • a (ColumnOrName) – One geometry column to check.

  • b (ColumnOrName) – Other geometry column to check.

Returns:

True if a and b intersect and False otherwise, as a boolean column.

Return type:

Column

sedona.spark.sql.st_predicates.ST_OrderingEquals(a: Column | ConnectColumn | str, b: Column | ConnectColumn | str) Column[source]

Check whether two geometries have identical vertices that are in the same order.

Parameters:
  • a (ColumnOrName) – One geometry column to check.

  • b (ColumnOrName) – Other geometry column to check.

Returns:

True if a and b are equal and False otherwise, as a boolean column.

Return type:

Column

sedona.spark.sql.st_predicates.ST_Overlaps(a: Column | ConnectColumn | str, b: Column | ConnectColumn | str) Column[source]

Check whether geometry a overlaps geometry b.

Parameters:
  • a (ColumnOrName) – Geometry column to check overlapping for.

  • b (ColumnOrName) – Geometry column to check overlapping of.

Returns:

True if a overlaps b and False otherwise, as a boolean column.

Return type:

Column

sedona.spark.sql.st_predicates.ST_Relate(a: Column | ConnectColumn | str, b: Column | ConnectColumn | str, intersectionMatrix: Column | ConnectColumn | str | None = None) Column[source]

Check whether two geometries are related to each other.

Parameters:
  • a (ColumnOrName) – One geometry column to check.

  • b (ColumnOrName) – Other geometry column to check.

  • intersectionMatrix (ColumnOrName) – intersectionMatrix column to check

Returns:

True if a and b touch and False otherwise, as a boolean column.

Return type:

Column

sedona.spark.sql.st_predicates.ST_RelateMatch(matrix1: Column | ConnectColumn | str, matrix2: Column | ConnectColumn | str) Column[source]

Check whether two DE-9IM are related to each other.

Parameters:
  • matrix1 (ColumnOrName) – One geometry column to check.

  • matrix2 (ColumnOrName) – Other geometry column to check.

Returns:

True if a and b touch and False otherwise, as a boolean column.

Return type:

Column

sedona.spark.sql.st_predicates.ST_Touches(a: Column | ConnectColumn | str, b: Column | ConnectColumn | str) Column[source]

Check whether two geometries touch.

Parameters:
  • a (ColumnOrName) – One geometry column to check.

  • b (ColumnOrName) – Other geometry column to check.

Returns:

True if a and b touch and False otherwise, as a boolean column.

Return type:

Column

sedona.spark.sql.st_predicates.ST_Within(a: Column | ConnectColumn | str, b: Column | ConnectColumn | str) Column[source]

Check if geometry a is within geometry b.

Parameters:
  • a (ColumnOrName) – Geometry column to check.

  • b (ColumnOrName) – Geometry column to check.

Returns:

True if a is within b and False otherwise, as a boolean column.

Return type:

Column

sedona.spark.sql.types module

class sedona.spark.sql.types.GeographyType[source]

Bases: UserDefinedType

deserialize(datum)[source]

Converts a SQL datum into a user-type object.

classmethod module()[source]

The Python module of the UDT.

needConversion()[source]

Does this type needs conversion between Python object and internal SQL object.

This is used to avoid the unnecessary conversion for ArrayType/MapType/StructType.

classmethod scalaUDT()[source]

The class name of the paired Scala UDT (could be ‘’, if there is no corresponding one).

serialize(obj)[source]

Converts a user-type object into a SQL datum.

classmethod sqlType()[source]

Underlying SQL storage type for this UDT.

class sedona.spark.sql.types.GeometryType[source]

Bases: UserDefinedType

deserialize(datum)[source]

Converts a SQL datum into a user-type object.

classmethod module()[source]

The Python module of the UDT.

needConversion()[source]

Does this type needs conversion between Python object and internal SQL object.

This is used to avoid the unnecessary conversion for ArrayType/MapType/StructType.

classmethod scalaUDT()[source]

The class name of the paired Scala UDT (could be ‘’, if there is no corresponding one).

serialize(obj)[source]

Converts a user-type object into a SQL datum.

classmethod sqlType()[source]

Underlying SQL storage type for this UDT.

class sedona.spark.sql.types.RasterType[source]

Bases: UserDefinedType

deserialize(datum)[source]

Converts a SQL datum into a user-type object.

classmethod module()[source]

The Python module of the UDT.

needConversion()[source]

Does this type needs conversion between Python object and internal SQL object.

This is used to avoid the unnecessary conversion for ArrayType/MapType/StructType.

classmethod scalaUDT()[source]

The class name of the paired Scala UDT (could be ‘’, if there is no corresponding one).

serialize(obj)[source]

Converts a user-type object into a SQL datum.

classmethod sqlType()[source]

Underlying SQL storage type for this UDT.

Module contents