Repository navigation
Is NAD27 / Clarke 1866 transformation expected to work in ST_Transform? Getting POINT (NaN NaN) on Fabric Spark #3466
Replies: 2 comments
|
Your GeoTools check passes because ST_Transform in 1.9.x doesn't use GeoTools for vector geometries. Since 1.9.0, To go back to the GeoTools path you already tested, set: spark.conf.set("spark.sedona.crs.geotools", "all")ST_Transform reads this from the active session when the expression is built, so setting it at runtime works. Re-run your queries after setting it. For the 4267 to 4326 NaN: proj4sedona defines NAD27 with optional grids ( I couldn't confirm from the code why your same-datum cases (to 4267) also return NaN, or whether Spark 4.1 is supported. Opening an issue with your repro would be the right next step for those. |
|
This is a bug in proj4sedona 0.1.6. Since 1.9.0, ST_Transform uses proj4sedona instead of GeoTools for vector geometries, so your GeoTools checks never touch this code. The lenient flag is also ignored on this path. The EPSG definitions for NAD27 use the NAD27 datum with optional NADCON and NTv2 grids. proj4sedona sends every transform that involves such a datum through WGS84, even when the source and the target are both NAD27. With no grid loaded, the NAD27 to WGS84 step fails, and the failed point is written as NaN. That is why your same-datum cases fail too. There are two ways to fix it on 1.9.1. I tested both on Spark 4.1.1 with The quick fix is to switch vector transforms back to GeoTools, which was the default before 1.9.0: spark.conf.set("spark.sedona.crs.geotools", "all")You can set it in a running session. With it, all your cases return finite values, and the same-datum cases match PROJ exactly. For NAD27 to WGS84, GeoTools uses a Helmert transformation, which was 3.6 m to 5 m from the NADCON result at my test points. If you need NADCON accuracy, keep the default setting and pass PROJ strings that point at the NADCON grid. This helper builds them from the EPSG code with pyproj on the driver: from pyproj import CRS
NADCON_CONUS = "https://cdn.proj.org/us_noaa_conus.tif"
def nad27(epsg, grid=True):
s = CRS.from_epsg(epsg).to_proj4().replace(" +type=crs", "")
return s.replace("+datum=NAD27", f"+ellps=clrk66 +nadgrids={NADCON_CONUS}" if grid else "+ellps=clrk66")
# NAD27 to WGS84, and back
df.selectExpr(f"ST_Transform(geom, '{nad27(32041)}', 'EPSG:4326') AS geom")
df.selectExpr(f"ST_Transform(geom, 'EPSG:4326', '{nad27(32041)}') AS geom")
# NAD27 to NAD27: no grid on either side
df.selectExpr(f"ST_Transform(geom, '{nad27(32041, False)}', '{nad27(4267, False)}') AS geom")proj4sedona 0.1.7 fixes the NaN for EPSG codes, and we will bump it in Sedona. With that fix and no grid, NAD27 to WGS84 by EPSG code is not shifted. So the PROJ string approach is still the one to use for NADCON accuracy. Spark 4.1 is supported in 1.9.1. Use sedona-spark-shaded-4.1_2.13-1.9.1 with geotools-wrapper 1.9.1-33.5. |
Uh oh!
There was an error while loading. Please reload this page.
Hi all,
I'm transforming legacy NAD27 Texas state plane coordinates and getting POINT (NaN NaN) with no error. NAD83, WGS84 and UTM transforms work fine in the same session. Can someone tell me whether this is expected, or whether I'm missing something in my setup?
Environment: Microsoft Fabric Spark notebook (PySpark), Spark version string 4.1.1.5.5.20260930.238388267, apache-sedona 1.9.1, geotools-wrapper 1.9.1-33.5 (version verified). Libraries come from an attached Fabric Environment, and spark.jars and spark.jars.packages are unset.
What I see:
Finite results: UTM EPSG:32614 to 4326, and NAD83 4326 to EPSG:2279.
POINT (NaN NaN): EPSG:32041, EPSG:32040 and EPSG:26714 to 4267, 4326 to 32041, and the datum step 4267 to 4326.
The three same-datum cases (to 4267) fail too, so no datum shift is involved.
The lenient flag and passing WKT instead of the code make no difference.
From PySpark, GeoTools CRS.decode("EPSG:32041", true) and findMathTransform both succeed.
The attached document has the full reproduction script (synthetic points) and the observed output.
My questions:
Is NAD27 / Clarke 1866 expected to work with Sedona 1.9.1 and geotools-wrapper 1.9.1-33.5?
Is the NAD27 to WGS84 datum shift expected to be available in the shaded geotools-wrapper?
Should an uncomputable transform raise an exception rather than return NaN, including with lenientMode = false?
Is Spark 4.1 supported by Sedona 1.9.1?
I haven't called GeoTools directly outside Sedona, so I can't say where the NaN originates. Happy to provide more detail or turn this into an issue.
Thanks for the project and for any pointers.
Sedona_Discussion_Post_NAD27_ST_Transform_returns_NaN_QA_dra.pdf
All reactions