Skip to content

grass.temporal: Fix swapped rows and cols in map metadata - #7681

Merged
petrasovaa merged 1 commit into
OSGeo:mainfrom
petrasovaa:tgis-rows-cols-fix
Jul 13, 2026
Merged

petrasovaa merged 1 commit into
OSGeo:mainfrom
petrasovaa:tgis-rows-cols-fix

Conversation

@petrasovaa

Copy link
Copy Markdown
Contributor

Bug

During writing tests for t.info, I found out that t.info reports the number of rows and columns of a registered raster or 3D raster map the other way round. It disagrees with r.info and r3.info for the same map:

g.region s=0 n=80 w=0 e=120 res=10   # 8 rows, 12 columns
r.info -g a | grep -E "^(rows|cols)="
rows=8
cols=12
t.info -g type=raster input=a | grep -E "^(rows|cols)="
cols=8
rows=12

The swap propagates from the region struct into the temporal database at registration time and out through t.info. number_of_cells is not affected, since it is the product of both.

This likely dates back to 2013 (I didn't verify).

Impact on existing data

t.info reads rows and cols from the temporal database, where they are stored when a map is registered. Maps registered before this fix keep the swapped values until they are registered again. Only new registrations are correct.

The ctypes interface assigned the number of columns to the rows key and
the number of rows to the cols key, for raster as well as 3D raster maps.
The swapped values are stored in the temporal database when a map is
registered and are reported by t.info, which therefore disagreed with
r.info and r3.info. The number of cells was not affected, because it is
the product of both.

Maps registered before this fix keep the swapped values in the temporal
database until they are registered again.

Update the doctests which asserted the swapped values and add a test
comparing the metadata read through the interface with the output of
r.info and r3.info.

The test was written with the help of Claude Code.
@petrasovaa petrasovaa added bug Something isn't working errata Include in errata (fixes wrongly computed results) labels Jul 13, 2026
@petrasovaa
petrasovaa requested a review from ninsbl July 13, 2026 13:02
@petrasovaa petrasovaa mentioned this pull request Jul 13, 2026

@ninsbl ninsbl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good catch. Wow, I am surprised I never noticed. Then, number of rows and columns has not been that top of mind as extent and resolution is what I use more regularly. Anyway, the fix and test looks good to me.

@ninsbl

ninsbl commented Jul 13, 2026

Copy link
Copy Markdown
Member

P.S.: Should this go into the errata, or is this not relevant enough, it is only reported metadata after all.

@github-actions github-actions Bot added Python Related code is in Python libraries tests Related to Test Suite labels Jul 13, 2026
@petrasovaa
petrasovaa enabled auto-merge (squash) July 13, 2026 14:31
@petrasovaa
petrasovaa merged commit 46db581 into OSGeo:main Jul 13, 2026
28 of 29 checks passed
@github-actions github-actions Bot added this to the 8.6.0 milestone Jul 13, 2026
@petrasovaa
petrasovaa deleted the tgis-rows-cols-fix branch July 14, 2026 06:31
echoix pushed a commit to wenzeslaus/grass that referenced this pull request Jul 14, 2026
The ctypes interface assigned the number of columns to the rows key and
the number of rows to the cols key, for raster as well as 3D raster maps.
The swapped values are stored in the temporal database when a map is
registered and are reported by t.info, which therefore disagreed with
r.info and r3.info. The number of cells was not affected, because it is
the product of both.

Maps registered before this fix keep the swapped values in the temporal
database until they are registered again.

Update the doctests which asserted the swapped values and add a test
comparing the metadata read through the interface with the output of
r.info and r3.info.

The test was written with the help of Claude Code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working errata Include in errata (fixes wrongly computed results) libraries Python Related code is in Python tests Related to Test Suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants