Repository navigation
Check the grid cell size against the clone when the reference system is projected - #339
Merged
Merged
Conversation
…is projected Add check_grid_cell_size: when the reference coordinate reference system is projected, convert the pixel size of the clone to metres through the linear unit of the system and compare it with GRID.grid; a relative difference above 1e-6 on either axis is a blocking problem naming both values, since the cell area scales the accumulated runoff quadratically. A geographic or absent system leaves the declared value as given and logs the raster resolution. Wire the check in both configuration formats under the input validation only.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #339 +/- ##
==========================================
+ Coverage 92.72% 92.75% +0.02%
==========================================
Files 60 61 +1
Lines 3985 4028 +43
Branches 502 510 +8
==========================================
+ Hits 3695 3736 +41
- Misses 234 235 +1
- Partials 56 57 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…on build The documentation build mocks osgeo, and the mocked SpatialReference does not support the union operator, so the eagerly evaluated return annotation of _spatial_reference broke the import under Python 3.13. Deferring the annotations, as the other modules of the package do, keeps the module importable with the mock.
camilabillerbeck
previously approved these changes
Sep 17, 2026
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.
Checklist
Description
rubem/validation/grid_cell_size.pywithcheck_grid_cell_size(grid, pixel_width, pixel_height, crs_wkt, file): when the reference coordinate reference system is projected, the pixel size of the clone is converted to metres through the linear unit of the system (SpatialReference.GetLinearUnits()) and compared withGRID.grid(raster_info.grid_sizein format 1.0); a relative difference above1e-6on either axis is a blocking problem naming the declared value, the pixel size in the unit of the system and in metres (implication: the cell area converts the accumulated runoff from mm to m3/s, so a wrong cell size scales it quadratically). A geographic system, an engineering system or the absence of a system (PCRaster maps without a georeference) yields no problem: one informational log line states the declared cell size and the resolution the raster offers.ModelConfigurationfor both configuration formats, right after the clone geometry and the reference CRS are known, and only undervalidate_input(the raster validation tier skipped by-s).tests/unit/validation/test_grid_cell_size.py): projected metres matching and mismatching, both sides of the tolerance (500.0000001 and 500.0002 pass, 500.001 and 500.002 block), a single differing axis, a US survey foot system converted to metres with both units in the reason, geographic and CRS-less rasters not compared (log asserted), and the loader wiring on the synthetic dataset for both formats, includingvalidate_input=False.gridis the metric cell size the user asserts, when it is compared and with which reference system (clone, then georeference raster, then DEM), what happens in geographic coordinates (the published basins), andrubem preprocess infoas the way to obtain the value. Changelog entry under Added.Related Issue
Motivation and context
GRID.gridwas typed by the user and never compared with the rasters, although the cell area scalesarnquadratically without any other symptom (finding 6 of the scientific review, accepted with the evaluation of when and how). The published basins are in degrees with a nominal metric resolution, so there the value must stay user-provided; in a projected system it can be checked.How has this been tested
python -m pytest -q -p no:cacheprovider --ignore=tests/integration/doc -n 4: 1021 passed, 1 skipped, onmainat 176f204 (Linux, Python 3.13, PCRaster 4.4.2).GetLinearUnits()1.0 for the metre system, 0.3048006096 for the US survey foot one).uvx ruff@0.16.4 format --check .anduvx ruff@0.16.4 check .: clean.sphinx-build -W -b html doc/source: no warnings, with the documentation's Python 3.13 environment (the first CI run failed there: the mockedosgeodoes not support the union operator in an eagerly evaluated annotation; the module now defers its annotations like the rest of the package).Left as written, for the maintainer: on a rotated or sheared affine the pixel size would be the norm of the affine columns, not
abs(pixel_width); the issue asks for the absolute values and a rotated clone is already refused at run time when PCRaster maps are written, so only the message would differ there.Screenshots