Skip to content

[GH-3121] Translate CF grid mapping parameters to CRS in netcdf.metadata - #3133

Merged
jiayuasu merged 3 commits into
apache:masterfrom
jiayuasu:feature/netcdf-cf-gridmapping-crs
Jul 21, 2026
Merged

[GH-3121] Translate CF grid mapping parameters to CRS in netcdf.metadata#3133
jiayuasu merged 3 commits into
apache:masterfrom
jiayuasu:feature/netcdf-cf-gridmapping-crs

Conversation

@jiayuasu

Copy link
Copy Markdown
Member

What changes?

  • Upgrade proj4sedona to 0.1.2 and translate CF grid_mapping attributes when NetCDF files omit crs_wkt/spatial_ref.
  • Preserve declared WKT precedence and derive WKT2 plus an EPSG code, when identifiable, from canonical CF projection parameters.
  • Carry the x/y coordinate units into translation so non-metre false origins are scaled correctly.
  • Add NetCDF fixtures and coverage for Lambert conformal conic, CDM UTM, and kilometre-based polar stereographic mappings, and update the documentation.

Why?

CF permits a CRS to be defined entirely by grid_mapping_name and its projection and ellipsoid attributes. These files currently return null crs and srid values from netcdf.metadata unless 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...HEAD
  • Integration fixtures cover a parameter-defined LCC, CDM UTM resolving to EPSG:32633, and kilometre polar stereographic false origins.

Dependency

Depends on jiayuasu/proj4sedona#113, which is merged. org.datasyslab:proj4sedona:0.1.2 still needs to be published to Maven Central before CI can resolve it.

Fixes #3121

jiayuasu added 2 commits July 20, 2026 10:18
….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).
@jiayuasu
jiayuasu marked this pull request as ready for review July 21, 2026 06:15
@jiayuasu
jiayuasu requested a review from Copilot July 21, 2026 06:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.2 and use CfGridMapping to translate CF grid mapping parameters into WKT2 + optional EPSG authority.
  • Extend NetCdfMetadataPartitionReader CRS 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.

Comment thread pom.xml
@jiayuasu jiayuasu added this to the sedona-1.9.1 milestone Jul 21, 2026
@jiayuasu
jiayuasu merged commit 07712ae into apache:master Jul 21, 2026
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Translate CF grid_mapping parameters to CRS in netcdf.metadata

2 participants