Skip to content

i.rectify: add test file #5919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jayneel-shah18
Copy link
Contributor

This PR introduces a comprehensive regression test suite for the i.rectify module in GRASS. The tests cover the core rectification workflows, including affine and polynomial transformations, flag-specific behaviors, and region/resolution control.

Tests Included

  • test_affine_rectification

    • Verifies a first-order (affine) polynomial transformation using cubic interpolation.
    • Ensures that spatial transformation and pixel values remain consistent with expected statistics.
  • test_polynomial_order2_rectification

    • Validates 2nd-order polynomial transformation using linear interpolation.
    • Tests numerical stability and interpolation accuracy when extending beyond affine geometry.
  • test_polynomial_order3_rectification

    • Verifies 3rd-order polynomial transformation with lanczos interpolation.
    • Demonstrates support for higher-order models and tests precision of the resampling algorithm.
  • test_region_restriction

    • Tests the -c flag which restricts the output to the current computational region.
    • Confirms geographic extents of rectified rasters match the region bounds (via r.info).
  • test_c_flag_with_resolution_override

    • Ensures that the -c flag takes precedence over the resolution= parameter.
    • Validates that output resolution aligns with the region and not the explicit input.
  • test_automatic_rectification

    • Uses the -a flag to automatically rectify all maps in the group.
    • Confirms multi-raster handling and that results match expected statistical summaries.
  • test_thin_plate_spline

    • Tests -t flag for thin plate spline (TPS) interpolation.
    • TPS is nonlinear and sensitive to control point configuration; this test validates the transformation correctness.
  • test_resolution_parameter

    • Verifies the resolution= parameter sets the desired output resolution when -c is not used.
    • Ensures output maps honor the specified resolution and dimensions.

The suite validates correctness using raster inputs and univariate statistics on rectified outputs. Looking forward to feedback and improvements!

@github-actions github-actions bot added Python Related code is in Python module imagery tests Related to Test Suite labels Jun 20, 2025
Comment on lines +237 to +239
info = gs.parse_command("r.info", map="rectify_band1res2", flags="g")
self.assertEqual(float(info["nsres"]), 2.0)
self.assertEqual(float(info["ewres"]), 2.0)
Copy link
Contributor

Choose a reason for hiding this comment

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

For r.info you can use format=json:

Suggested change
info = gs.parse_command("r.info", map="rectify_band1res2", flags="g")
self.assertEqual(float(info["nsres"]), 2.0)
self.assertEqual(float(info["ewres"]), 2.0)
info = gs.parse_command("r.info", map="rectify_band1res2", format="json")
self.assertEqual(info["nsres"], 2.0)
self.assertEqual(info["ewres"], 2.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
imagery module 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