Repository navigation
r.sim: Refuse to run in latitude-longitude projects - #7978
Merged
Merged
Conversation
r.sim.water and r.sim.sediment convert the cell size to meters with G_database_units_to_meters_factor(), but the slope is computed from the cell size in project units. In a latitude-longitude project the factor is 1, so one degree was taken as one meter without any warning, and the results were meaningless. A run in EPSG:4326 at 1 degree resolution gave the same output as a run in an XY project at 1 m. Both tools now end with an error in a latitude-longitude project right after parsing, before reading any input, and ask the user to reproject the data to a projected coordinate system. The error message follows the one used by r.topidx, r.gwflow, and r.solute.transport. The documentation of both tools states the requirement. There are no output changes in projected or XY projects. Written with the help of Claude Code.
echoix
approved these changes
Sep 30, 2026
wenzeslaus
enabled auto-merge (squash)
September 30, 2026 21:12
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.
r.sim.water and r.sim.sediment silently take one degree as one meter in a latitude-longitude project, so the results there are meaningless. The cell size is converted to meters with the units-to-meters factor, but that factor is 1 in a latitude-longitude project, and the slope is computed from the cell size in project units anyway. A run in EPSG:4326 at 1 degree gives exactly the same output as a run in an XY project at 1 m, and there is no warning.
This makes both tools end with an error in a latitude-longitude project and ask the user to reproject the data to a projected coordinate system. Nothing changes in projected or XY projects.
Details (AI generated)
G_projection() == PROJECTION_LLright afterG_parser()in bothmain.cfiles, before the seed, the region, or any input is read. The same check is in r.topidx, r.gwflow, and r.solute.transport.Lat/Long project is not supported by r.sim.water. Please reproject the data to a projected coordinate system.The first sentence is the one from those three tools. Their second sentence, "Please reproject map first.", does not say what to reproject to, so the second sentence is new..htmlfiles mirror the.mdfiles.Tests
r_sim_water_latlong_test.pyandr_sim_sediment_latlong_test.py(new, one test each, 0.2 s and 0.6 s):testsdirectory, so each test is next to its tool.testsdirectories pass in 20 s. The r.sim.water gunittest suite (5 tests, 1 skipped) and the r.sim.sediment gunittest suite (1 test) pass in nc_spm_08_grass7.Squash-merge commit message
Title:
Body:
The analysis, code and tests were done with Claude Code (Opus) and reviewed by me.