You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@sedona.apache.org by "DrJohnDale (via GitHub)" <gi...@apache.org> on 2026/09/28 10:14:13 UTC

[D] ST_ClosestPoint gives an error for two geometries [sedona]

GitHub user DrJohnDale created a discussion: ST_ClosestPoint gives an error for two geometries

If i run the following code:
```
import sedona.db

# Connect to SedonaDB
sd = sedona.db.connect()

# Run ST_ClosestPoint using WKT or geometry constructors
result = sd.sql(
    """
    SELECT ST_AsText(
        ST_ClosestPoint(
            ST_GeomFromText('LINESTRING(0 0, 10 10)'),
            ST_Point(5, 0)
        )
    ) AS closest_point
"""
)

result.show()
```

I get the error 
sedonadb._lib.SedonaError: st_closestpoint(geometry, geometry): No kernel matching arguments

GitHub link: https://github.com/apache/sedona/discussions/3418

----
This is an automatically sent email for issues@sedona.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@sedona.apache.org


Re: [D] ST_ClosestPoint gives an error for two geometries [sedona]

Posted by "DrJohnDale (via GitHub)" <gi...@apache.org>.
GitHub user DrJohnDale added a comment to the discussion: ST_ClosestPoint gives an error for two geometries

Thanks for the help. We are working with linestrings. Is there a plan to have a geometry implementation? similar to what you get in databases such as postgres?

GitHub link: https://github.com/apache/sedona/discussions/3418#discussioncomment-18639421

----
This is an automatically sent email for issues@sedona.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@sedona.apache.org


Re: [D] ST_ClosestPoint gives an error for two geometries [sedona]

Posted by "wmorin (via GitHub)" <gi...@apache.org>.
GitHub user wmorin added a comment to the discussion: ST_ClosestPoint gives an error for two geometries

In SedonaDB 0.4.1 ST_ClosestPoint only has a geography kernel (from s2geography), there is no geometry one yet, so any (geometry, geometry) call fails with "No kernel matching arguments", whatever constructor you use. The SQL reference page lists a geometry signature, but I couldn't find a geometry implementation in the 0.4.1 tag or on main. ST_ShortestLine is in the same situation.

For a linestring, this works in 0.4.1 with planar geometry:

```sql
SELECT ST_AsText(
    ST_LineInterpolatePoint(
        ST_GeomFromText('LINESTRING(0 0, 10 10)'),
        ST_LineLocatePoint(ST_GeomFromText('LINESTRING(0 0, 10 10)'), ST_Point(5, 0))
    )
) AS closest_point
```

Output: `POINT(2.5 2.5)`, the perpendicular foot of (5 0) on the line. ST_LineLocatePoint returns the fraction along the line nearest to the point, and ST_LineInterpolatePoint turns it back into a point. It only works when the first argument is a single linestring. For a polygon you can wrap it in `ST_Boundary(...)` to get the closest point on its outline.

If your data is lon/lat and you want spherical distance, the geography version already works:

```sql
SELECT ST_AsText(ST_ClosestPoint(ST_GeogFromText('LINESTRING(0 0, 10 10)'), ST_GeogPoint(5, 0)))
```

That returns `POINT(2.466474353124253 2.5021583528406395)`, slightly off 2.5 2.5 because it follows the great circle.

The registration is here: https://github.com/apache/sedona-db/blob/apache-sedona-db-0.4.1/c/sedona-s2geography/src/kernels.rs#L110-L119

Is your first geometry always a linestring, or do you also need polygons?

GitHub link: https://github.com/apache/sedona/discussions/3418#discussioncomment-18638657

----
This is an automatically sent email for issues@sedona.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@sedona.apache.org


Re: [D] ST_ClosestPoint gives an error for two geometries [sedona]

Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
GitHub user jiayuasu added a comment to the discussion: ST_ClosestPoint gives an error for two geometries

CC @paleolimbot 

I think we have a geometry function here? https://github.com/apache/sedona-db/issues/174

GitHub link: https://github.com/apache/sedona/discussions/3418#discussioncomment-18644881

----
This is an automatically sent email for issues@sedona.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@sedona.apache.org