The error occurs because Databricks (based on GEOS/OGC standards) expects coordinates in Well-Known Text (WKT) that fall into valid ranges:
-
Longitude (XX or first coordinate): −180≤X≤180−180≤X≤180
-
Latitude (YY or second coordinate): −90≤Y≤90−90≤Y≤90
Your SQL includes:
st_point(10D, 90D)
Here, 9090 is valid for latitude, but if you ever used a value above 9090 it would trigger a WKT parse error, commonly seen with "Invalid coordinate value" errors in Databricks geospatial functions.
Key Points
-
Latitude must never exceed ±90±90.
-
Longitude must never exceed ±180±180.
How To Fix
-
Double-check your coordinate values in st_point(x, y) calls.
-
Make sure the yy (second) value is not greater than 9090 nor less than −90−90.
-
If your input is correct, ensure you are not accidentally swapping longitude/latitude order.
Sample Correction
If you originally wrote:
SELECT st_astext(st_point(10D, 90D)) AS point_geom
This is valid because 9090 is within allowed latitude. If you wrote 9191 or higher, that would fail. If your error persists, make sure:
-
Your actual input values are not outside the range.
-
You're not using 90 or -90 as longitude (first value).
Example Full Query Correction
WITH points AS (
SELECT st_astext(st_point(30D, 10D)) AS point_geom
UNION SELECT st_astext(st_point(10D, 90D)) AS point_geom
UNION SELECT st_astext(st_point(40D, 40D)) AS point_geom
)
SELECT st_geoglength(st_astext(st_makeline(collect_list(st_geomfromtext(point_geom))))
FROM points
This query should work if all coordinate values are within range. If it does not, double-check for typos or data issues (like using degree symbols, non-decimal values, or non-numeric strings).
Additional Guidance
-
Use ST_IsValid() only checks general validity, not coordinate domain. It won't catch domain errors for WKT parsing. Always validate ranges.
-
If parsing from external data, preprocess to check for invalid coordinates before using them in SQL.
-
Refer to Databricks ST_* function docs for expected ranges.
For more troubleshooting, paste your exact raw input and check for invisible characters, decimals/commas, or try running each point individually to isolate the bad value.
Summary:
Ensure all coordinates are inside valid latitude (±90±90) and longitude (±180±180) domains. Correct any values outside this range, as WKT parsing in Databricks will fail otherwise.