Repository navigation
r.in.gdal: Compare only the horizontal CRS with the project - #7936
Merged
Merged
Conversation
Data with a compound or geographic 3D CRS was rejected even by a project created from the same file. Same fix in r.external, v.in.ogr and v.external, plus a message that the vertical component is ignored.
Contributor
|
What about adding support for vertical CRS on projects? Make it optional but enforce it if it is set. |
Contributor
Author
This is a bug fix, adding that feature would be different PR, likely more complicated. |
metzm
approved these changes
Sep 23, 2026
metzm
left a comment
Contributor
There was a problem hiding this comment.
Thanks for this fix!
As I understand, a vertical CRS is specific to a dataset, and it is perfectly valid to have different datasets with the same horizontal, but different vertical CRSs. GDAL can on reprojection apply vertical CRS info to e.g. elevation values, I've been testing this before.
Users should reproject to a 2D CRS with GDAL to be on the safe side before importing into GRASS.
Contributor
|
Fixes #7336 |
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.
Bug
Importing data with a compound CRS (e.g.,
NAD83(2011) / North Carolina (ftUS) + NAVD88 height (ftUS), failed with "Coordinate reference system of dataset does not appear to match current project" even when the project was created from that very file. r.import had no way around it: its temporary project is created from the file too, so the import into it failed the same way.Project creation stores only the horizontal SRID (
EPSG:6543) while the CRS check compared the file's full compound CRS against it withOSRIsSameEx(), which never matches. Geographic 3D data (EPSG:4979) had the same problem in the other direction: a project created from such a file getsPROJ_SRID = EPSG:4979and then rejects ordinary 2D lat-lon data.Fix
GRASS has no vertical CRS, so
check_projection()now compares the horizontal components only, usingOSRDemoteTo2D()on clones of both CRSs (GDAL >= 3.1; GRASS requires 3.7). The import itself is unchanged: it never transforms with the file CRS, and r.proj/v.proj already get a horizontal pipeline from PROJ.Since this drops information the file carries, the tools now say so:
Vertical CRS <NAVD88 height (ftUS)> of the dataset is ignoredThe vertical component of the dataset CRS is ignored(geographic 3D)The same change is applied to the four copies of the check code in r.in.gdal, r.external, v.in.ogr and v.external. The lidar/PDAL importers compare via
G_compare_projections(), which is already horizontal only.Tests
New pytest files for the raster tools (r.in.gdal, r.external) and the vector tools (v.in.ogr, v.external), with data generated as small GDAL/OGR VRT files, covering compound and geographic 3D CRSs in both project and file, the message, and that a different horizontal CRS is still rejected. Against the unfixed build 20 of the 28 tests fail.
--
Implemented with the help of Claude Code.