[GH-3121] Translate CF grid mapping parameters to CRS in netcdf.metadata - #3133
Merged
jiayuasu merged 3 commits intoJul 21, 2026
Merged
Conversation
….metadata Files that define their CRS in the canonical CF form (grid_mapping_name plus projection/ellipsoid parameters, no crs_wkt) previously reported null crs/srid. The grid mapping attributes are now translated through proj4sedona 0.1.2's CF grid mapping support: crs carries the derived WKT2 and srid its EPSG identity (e.g. utm_zone_number 33 -> 32633). false_easting/false_northing are read in the projection coordinate variables' units per CF, so kilometre grids convert correctly. A latitude_longitude mapping is translated only when its attributes positively identify the Earth figure — the WGS 84 assumption GDAL applies to a bare geographic mapping is never reported as if the file declared it. This subsumes the previous name-based EPSG:4326 inference (and its contradiction vetoes), which moved into proj4sedona. Requires the proj4sedona 0.1.2 release (version bumped here).
Contributor
There was a problem hiding this comment.
Pull request overview
Updates Sedona’s netcdf.metadata reader to populate crs/srid even when a NetCDF file omits crs_wkt/spatial_ref, by translating canonical CF grid_mapping parameters via proj4sedona (GH-3121).
Changes:
- Upgrade proj4sedona dependency to
0.1.2and useCfGridMappingto translate CF grid mapping parameters into WKT2 + optional EPSG authority. - Extend
NetCdfMetadataPartitionReaderCRS resolution to fall back to parameter translation when WKT attributes are absent. - Update/expand NetCDF metadata tests and documentation to reflect the new CRS behavior and add fixtures coverage.
Reviewed changes
Copilot reviewed 4 out of 7 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| spark/common/src/test/scala/org/apache/sedona/sql/netcdfMetadataTest.scala | Updates expectations and adds new fixtures-based tests for CF parameter translation (LCC/UTM/polar stereographic km). |
| spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/io/netcdfmetadata/NetCdfMetadataPartitionReader.scala | Adds CF parameter translation fallback (via proj4sedona) when no WKT is declared; refactors SRID lookup. |
| pom.xml | Bumps proj4sedona version to 0.1.2. |
| docs/tutorial/files/netcdfmetadata-sedona-spark.md | Documents new CRS resolution precedence and parameter-based translation behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes?
grid_mappingattributes when NetCDF files omitcrs_wkt/spatial_ref.Why?
CF permits a CRS to be defined entirely by
grid_mapping_nameand its projection and ellipsoid attributes. These files currently return nullcrsandsridvalues fromnetcdf.metadataunless they duplicate that definition as WKT.The translation remains in proj4sedona, keeping this data source independent of the optional GeoTools runtime.
Validation
netcdfMetadataTest: 60 tests passed against the merged proj4sedona changes.git diff --check origin/master...HEADDependency
Depends on jiayuasu/proj4sedona#113, which is merged.
org.datasyslab:proj4sedona:0.1.2still needs to be published to Maven Central before CI can resolve it.Fixes #3121