INNER CODE UNIT · Python

haversine_distance

jeroenjanssens/python-polars-the-definitive-guide · plugins/polars_geo/polars_geo/__init__.py:19

def haversine_distance(from_point: IntoExpr, to_point: IntoExpr) -> pl.Expr:
    return register_plugin_function(
        plugin_path=PLUGIN_PATH,
        args=[from_point, to_point],
        function_name="haversine_distance",
        is_elementwise=True,
    )


@pl.api.register_expr_namespace("geo")
class Geo:
    def __init__(self, input_expression: pl.Expr):
        self._input_expression = input_expression

    def point_in_polygon(self, polygon: list[list[pl.Float64]]) -> pl.Expr:
        return point_in_polygon(self._input_expression, polygon)

    def haversine_distance(self, to_point: list[pl.Float64]) -> pl.Expr:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…