Skip to content

feat: add compare, pixel-info and xyz raster query commands - #303

Merged
giswqs merged 20 commits into
mainfrom
feat/289-raster-query
Oct 27, 2026
Merged

giswqs merged 20 commits into
mainfrom
feat/289-raster-query

Conversation

@giswqs

@giswqs giswqs commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Adds raster comparison, pixel queries and XYZ export through shared Rust algorithms, CLI/MCP, Python and JavaScript/WebAssembly. Part of #289.

Behavior

  • compare follows GDAL report ordering and skip options, returns a difference count, and exposes per-band/overview/mask counts and maximum errors in JSON. Binary reads stream in chunks; read failures propagate as errors. Pixel comparisons use shared block-aligned strips. Comparison-only TIFF metadata is fetched separately from ordinary lazy opens.
  • pixel-info accepts positions or vector points/centroids, CRS selection, overviews, four interpolation methods, field selection and GeoJSON/CSV/text/value/JSON or native vector-file output. CLI -o - writes text to stdout. Invalid Python output options fail before reads/writes; ambiguous vector output field collisions fail before writing.
  • xyz streams selected pixels/bands, windows, skips, nodata replacement and text delimiters in native Rust/CLI. It rejects non-finite nodata that cannot be converted into the first selected integer working type, matching GDAL's conversion failure. JavaScript returns a complete string; its comparisons reuse each copied input buffer.

Validation

Tested in a local environment with GDAL 3.13.3. Validation covers the 606-test core integration suite, 16 MCP tests, five CLI tests, 18 Python query/dataset tests and three release-WASM/Node tests. Final diagnostic changes pass 14 focused Rust tests, five CLI tests, eight Python query tests and the current release-WASM query test. Optimized CLI builds, typing/stubtest, workspace Clippy and changed-file pre-commit pass.

The registered raster-query script compares real USGS, Landsat, OPERA, ECOSTRESS, NLCD and netCDF inputs and derived copies: 100 cases, 96 exact, three within documented numeric tolerances, and one known internal-mask report difference. XYZ has 11 byte-identical text cases plus a shared refusal of non-finite integer nodata. Pixel-info has 64 exact and three within 4e-14 relative/one ULP. Compare has 20 exact report/exit-status cases and the known mask-report difference: GDAL's report says 1,863,354 per band; its direct mask reads and Terrio count 2,568,634. This difference is retained explicitly, not treated as exact agreement.

Regressions cover truncated HTTP reads in either comparison operand, CRS-less position layers, reserved properties/vector field collisions, integer GeoJSON interpolation, literal marker strings, invalid output options, stdout output and single extraction of each WASM input buffer. GDAL 3.13.3 directly confirms the CRS-less pixel default, copied GeoJSON property precedence and integer raw/unscaled interpolation behavior.

I/O evidence

A before/after local HTTP range-server probe on real cog.tif (610,612 bytes) records one request/65,536 served body bytes for ordinary lazy info, four requests/1,221,224 bytes for comparing two URLs, and two requests/610,612 bytes for XYZ skip 3. Counts and outputs are unchanged on this fixture. Earlier 51 MB USGS measurements remain documented: two cubic queries read 1.8 MB in three requests; a bounded XYZ window reads 0.9 MB in two requests.

Scope and limits

  • Copied attributes can override reserved GeoJSON properties and repeat CSV names, matching GDAL. Rename/select input fields to retain computed properties; vector-file output rejects collisions.
  • A CRS-less position layer defaults to pixel coordinates. Interpolated integer GeoJSON raw values truncate while unscaled values retain fractions, matching GDAL.
  • Three numeric comparisons differ within projection/scale arithmetic tolerances. CRS WKT wording and metadata-value message ordering differ as documented. The internal-mask report mismatch remains explicit.
  • Complex rasters, VRT LocationInfo, input-driver/open options, pipelines and some GDAL container/multiband reporting modes are unsupported. RPC metadata is read from GeoTIFF tags rather than external RPC text files.
  • JavaScript XYZ materializes the full string; use windows/skips for large exports. Native XYZ streams. Floating NaN nodata matching in XYZ differs from gdal2xyz's equality behavior.

CSV comparisons retain the original numeric precision: no geometry-coordinate rounding precedes exact/tolerance classification. The 67-case pixel-info rerun still gives 64 exact and three within tolerance. Input transformation failure is intentionally fatal, matching a direct GDAL 3.13.3 projected-raster probe. Diagnostic JSON uses null for non-finite numbers; GDAL-compatible GeoJSON retains its non-standard tokens, and text labels non-finite locations explicitly.

Summary by CodeRabbit

  • New Features
    • Added raster comparison with text or JSON reports and options to skip selected comparison checks.
    • Added pixel queries by coordinates or vector dataset, with multiple sampling methods and output formats including GeoJSON, CSV, text, and JSON.
    • Added XYZ raster export with band selection, sampling intervals, windowing, and nodata options.
    • These capabilities are available through the CLI, Python, and JavaScript APIs.
  • Documentation
    • Added usage examples and option references for the new raster tools.

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 19 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: eb434ad7-a3a6-412b-aaee-9630bedb00ff
Commits

Reviewing files that changed from the base of the PR and between 3eb4cfc and 6a244d9.

Files selected for processing: 8
  • NOTICE
  • crates/terrio/NOTICE
  • crates/terrio/src/ops/pixel_info.rs
  • crates/terrio/src/ops/xyz.rs
  • docs/cli.md
  • python/python/terrio/_terrio.pyi
  • python/src/query.rs
  • python/tests/test_raster_query.py
Walkthrough

This pull request adds raster comparison, pixel-info queries, and XYZ export to the Rust library, CLI/MCP, Python, and JavaScript interfaces. It also adds tests, GDAL conformance checks, documentation, and attribution notices.

Changes: Raster query operations

Layer / File(s) Summary
Raster comparison
crates/terrio/src/ops/compare.rs, crates/terrio/src/geotiff.rs, crates/terrio/src/cog.rs, crates/terrio/src/ops/vrt/virtual_raster.rs, crates/terrio/src/ops/mod.rs, crates/terrio/NOTICE, NOTICE
Adds byte and dataset comparisons, including metadata, bands, overviews, masks, and pixels. Adds comparison-only TIFF metadata reads and per-band raster data-type reporting.
Pixel query and sampling
crates/terrio/src/ops/pixel_info.rs, crates/terrio/src/ops/mod.rs
Adds position and vector-layer queries, coordinate conversion, four sampling methods, cached block reads, and GeoJSON, CSV, text, value, JSON, and point-layer outputs.
XYZ raster export
crates/terrio/src/ops/xyz.rs, crates/terrio/src/ops/mod.rs
Adds validated, strip-based XYZ output with band selection, sampling intervals, windows, nodata options, and file writing.

CLI and MCP integration

Layer / File(s) Summary
CLI commands and MCP handling
crates/terrio-cli/src/cmd/*, crates/terrio-cli/src/lib.rs, crates/terrio-cli/src/mcp.rs, crates/terrio-cli/tests/*
Adds compare, pixel-info (alias locationinfo), and xyz commands. Carries command exit statuses through CLI and MCP execution, and adds command and MCP integration tests.
CLI documentation
docs/cli.md
Documents command options, input and output forms, exit statuses, and reported comparisons with GDAL.

Language APIs and conformance

Layer / File(s) Summary
Python and JavaScript APIs
python/src/query.rs, python/src/lib.rs, python/python/terrio/*, python/tests/test_raster_query.py, js/src/query.rs, js/src/lib.rs, js/tests/node.test.mjs
Adds bindings for the three operations, exports the Python functions, and tests their inputs and outputs.
API documentation
docs/python.md, docs/javascript.md, docs/rust.md
Adds examples and usage details for the Python, JavaScript, and Rust interfaces.
GDAL conformance checks
scripts/compare_raster_query_with_gdal.py, scripts/conformance.py, docs/testing.md, ROADMAP.md
Adds a harness and registered suite for comparing the operations with GDAL tools. Documents conformance results and raster-query I/O measurements, and marks the roadmap item complete.

Priority: Normal

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Caller as CLI or API caller
  participant Query as pixel_info
  participant Raster as LazyRaster
  Caller->>Query: positions and query options
  Query->>Raster: read raster blocks and band metadata
  Raster-->>Query: pixel samples and metadata
  Query-->>Caller: PixelInfo results
Loading

Possibly related issues

  • opengeos/terrio#289 — Tracks GDAL CLI parity for compare, pixel-info, and XYZ export, which this pull request adds across Terrio interfaces.

Possibly related PRs

  • opengeos/terrio#265 — Changes GeoTIFF metadata and overview handling used by the comparison implementation.
  • opengeos/terrio#261 — Changes raster metadata behavior for CRS, geotransforms, and comparison inputs.
  • opengeos/terrio#219 — Adds RPC metadata reading used by the new RPC comparison option.
Merge Risk: Low · previous review 3eb4c

The new compare, pixel-info and xyz commands look sound, and the earlier robustness concerns have been addressed. Before merging, add the missing GDAL copyright attributions, decide how the known mask difference should count under --strict, and fix the small stub, test and docs inaccuracies.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely summarizes the main change: adding the compare, pixel-info, and xyz raster query commands across the project.
Docstring Coverage Passed Docstring coverage is inconclusive: files from earlier reviews still need to be rechecked within the check's analysis limits. Not blocking.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the pixels bright,
Then counts the differences right.
It samples blocks and prints XYZ,
With Python, Rust, and JS in play.
“The rasters match!” it hops away.

Comment @coderabbitai help to get the list of available commands.

Comment thread crates/terrio-cli/src/cmd/pixel_info.rs Resolved
Comment thread crates/terrio-cli/src/cmd/pixel_info.rs Resolved
Comment thread crates/terrio/src/ops/xyz.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the CLI pixel-info command and the xyz op in full. I did not read the 1,200-line compare op, the pixel_info op, the Python or JS bindings, or the tests in any depth, so this review is partial. Three inline comments are posted.

Bugs

  • --layer typo falls back silently (crates/terrio-cli/src/cmd/pixel_info.rs:92). When the layer name matches nothing, the command uses ds.layers[0] instead of returning an error. Confidence: medium-high.
  • xyz strip-size arithmetic can overflow (crates/terrio/src/ops/xyz.rs:122). x_size * n * 8 can overflow usize, which panics in debug and wraps in release. The .max(block.min(256)) term can also push a strip past the ~8 MB budget. Confidence: low-medium.

Security

  • Nothing found in the files I read.

Performance

  • pixel-info with no positions blocks on stdin (crates/terrio-cli/src/cmd/pixel_info.rs:105). It reads stdin to EOF, which could hang when the command runs as an MCP tool over stdio. Confidence: medium.

Quality

  • None found in the files I read.

CLAUDE.md (AGENTS.md)

  • The PR adds regression tests (CLI, MCP, Python, JS) and registers GDAL comparisons in scripts/conformance.py, as the guidelines ask.
  • I did not check NOTICE attribution for the ported algorithms (for example the gdal2xyz formatting logic) or the ROADMAP.md update. Please confirm both.

Change size

Compared: the whole PR against main (merge base 5f4a527 to PR head a55773e)

Metric Value
Files changed 26 (11 added, 15 modified, 0 removed, 0 renamed)
Size before 639.8 KB
Size after 819.0 KB
Total size change +179.1 KB
File Before After Change
crates/terrio/src/ops/compare.rs 0 B 46.1 KB +46.1 KB
crates/terrio/src/ops/pixel_info.rs 0 B 41.7 KB +41.7 KB
scripts/compare_raster_query_with_gdal.py 0 B 22.6 KB +22.6 KB
python/src/query.rs 0 B 12.6 KB +12.6 KB
js/src/query.rs 0 B 11.5 KB +11.5 KB
crates/terrio/src/ops/xyz.rs 0 B 10.5 KB +10.5 KB
crates/terrio-cli/src/cmd/pixel_info.rs 0 B 7.7 KB +7.7 KB
crates/terrio-cli/tests/raster_query.rs 0 B 4.5 KB +4.5 KB
python/tests/test_raster_query.py 0 B 3.9 KB +3.9 KB
crates/terrio/src/geotiff.rs 44.3 KB 47.6 KB +3.3 KB
crates/terrio-cli/src/cmd/xyz.rs 0 B 3.0 KB +3.0 KB
crates/terrio-cli/src/cmd/compare.rs 0 B 2.3 KB +2.3 KB
python/python/terrio/_terrio.pyi 36.0 KB 37.7 KB +1.7 KB
scripts/conformance.py 72.5 KB 74.2 KB +1.7 KB
crates/terrio-cli/tests/mcp.rs 13.5 KB 15.2 KB +1.7 KB
js/tests/node.test.mjs 88.7 KB 90.3 KB +1.6 KB
crates/terrio-cli/src/mcp.rs 20.9 KB 21.9 KB +0.96 KB
crates/terrio-cli/src/lib.rs 10.1 KB 11.0 KB +0.86 KB
crates/terrio-cli/src/cmd/mod.rs 1.3 KB 1.9 KB +0.60 KB
python/python/terrio/init.py 4.2 KB 4.3 KB +82 B

Sizes use 1 KB = 1024 B. The table above lists the 20 largest changes (the full PR touches 26 files).

Comment thread crates/terrio-cli/src/cmd/xyz.rs Resolved
Comment thread crates/terrio/src/ops/xyz.rs Resolved
Comment thread crates/terrio/src/geotiff.rs Resolved
Comment thread crates/terrio-cli/src/mcp.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

This is a partial review. I read ops/xyz.rs, the CLI compare and xyz commands, the GeoTIFF tag changes, and the MCP exit-status handling. I did not read ops/compare.rs, ops/pixel_info.rs, the Python and JS bindings, the docs, or the conformance script. I ran no tests or builds.

Bugs

  • RATIONAL TIFF tags (geotiff.rs:222): The denominator isn't checked, so a zero gives inf/NaN in TIFFTAG_XRESOLUTION/YRESOLUTION. chunks(8) plus c[..4]/c[4..] would panic on a short trailing chunk. Suggest chunks_exact(8) and skipping non-finite values. Confidence: medium.
  • terrio xyz output file (cmd/xyz.rs:75): The output file is created and truncated before options are validated, so a bad --skip 0 or --srcwin leaves an empty file. It also overwrites the target if the output path equals the input path. Confidence: low–medium.

Security

  • Nothing found in the code I read.

Performance

  • xyz strip sizing (ops/xyz.rs:122): The row count has a floor of block.min(256) that ignores the 8 MiB budget. A very wide, many-band raster can read hundreds of MB per strip. x_size * n * 8 is also unchecked and could overflow on 32-bit/WASM. Confidence: low–medium.

Quality

  • MCP failure detection (mcp.rs:236): stderr_failed scans combined stdout and stderr for terrio: and error: prefixes, so a report line on stdout with those prefixes could be classified as a failure. Matching only stderr would be sturdier. Confidence: low.
  • The PR description says documentation and the remote-COG transfer measurement were still in progress. AGENTS.md asks for I/O changes to be measured, so check that this evidence is added before merge.

CLAUDE.md

  • Shared logic is in crates/terrio, the CLI and bindings are thin, and the NOTICE files and conformance suite were updated. No violations found in what I read.

Change size

Compared: the whole PR against main (merge base 5f4a527 to PR head 5dd9566).

Metric Value
Files changed 33 (11 added, 22 modified, 0 removed, 0 renamed)
Size before 822.3 KB
Size after 1014.3 KB
Total size change +192.0 KB
File Before After Change
crates/terrio/src/ops/compare.rs 0 B 46.1 KB +46.1 KB
crates/terrio/src/ops/pixel_info.rs 0 B 41.7 KB +41.7 KB
scripts/compare_raster_query_with_gdal.py 0 B 22.6 KB +22.6 KB
python/src/query.rs 0 B 12.6 KB +12.6 KB
js/src/query.rs 0 B 11.5 KB +11.5 KB
crates/terrio/src/ops/xyz.rs 0 B 10.5 KB +10.5 KB
crates/terrio-cli/src/cmd/pixel_info.rs 0 B 7.7 KB +7.7 KB
docs/cli.md 53.8 KB 61.3 KB +7.5 KB
crates/terrio-cli/tests/raster_query.rs 0 B 4.5 KB +4.5 KB
python/tests/test_raster_query.py 0 B 3.9 KB +3.9 KB
crates/terrio/src/geotiff.rs 44.3 KB 47.6 KB +3.3 KB
crates/terrio-cli/src/cmd/xyz.rs 0 B 3.0 KB +3.0 KB
crates/terrio-cli/src/cmd/compare.rs 0 B 2.3 KB +2.3 KB
python/python/terrio/_terrio.pyi 36.0 KB 37.7 KB +1.7 KB
scripts/conformance.py 72.5 KB 74.2 KB +1.7 KB
crates/terrio-cli/tests/mcp.rs 13.5 KB 15.2 KB +1.7 KB
js/tests/node.test.mjs 88.7 KB 90.3 KB +1.6 KB
docs/rust.md 18.5 KB 19.7 KB +1.2 KB
docs/python.md 16.3 KB 17.4 KB +1.1 KB
crates/terrio-cli/src/lib.rs 10.1 KB 11.1 KB +1.0 KB

Comment thread crates/terrio/src/ops/xyz.rs Resolved
Comment thread crates/terrio/src/ops/xyz.rs Resolved
Comment thread crates/terrio-cli/src/mcp.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read ops/xyz.rs and terrio-cli/src/mcp.rs in full. I did not read compare.rs (1208 lines), pixel_info.rs (1043 lines), the Python and JS bindings, the CLI command files or the conformance script. The PR description's GDAL parity and laziness numbers are the author's and I did not check them.

Bugs

  • MCP failure detection (medium). stderr_failed in mcp.rs treats compare and pixel-info exit statuses as results unless stderr starts with terrio: or error: . A panic (exit 101, stderr starting thread 'main' panicked) would be reported as a normal result with isError: false. A fix is to also treat unexpected exit codes as failures.

Security

  • Nothing found in the code I read. The MCP server passes arguments as an array to a child process, with no shell.

Performance

  • xyz per-value allocation (medium, minor). The inner loop in xyz.rs allocates a String for every value and coordinate through to_string and format!. Writing straight into the buffer would be faster for large rasters.

Quality

  • Duplicated validation in xyz.rs (high). write_xyz calls check_xyz and then repeats the same checks. Having check_xyz return the resolved values would avoid drift between the two copies.

CLAUDE.md (AGENTS.md)

  • The PR covers the guideline items I could see in the file list: Rust core with thin CLI, Python and JS bindings, NOTICE updates, docs, a conformance suite and tests. I did not confirm that CI is green.

Change size

The whole PR against main (merge base 2d71f94 to PR head 8f47068).

Metric Value
Files changed 32 (11 added, 21 modified, 0 removed, 0 renamed)
Size before 656.5 KB
Size after 851.7 KB
Total size change +195.2 KB
File Before After Change
crates/terrio/src/ops/compare.rs 0 B 46.1 KB +46.1 KB
crates/terrio/src/ops/pixel_info.rs 0 B 41.7 KB +41.7 KB
scripts/compare_raster_query_with_gdal.py 0 B 22.6 KB +22.6 KB
python/src/query.rs 0 B 12.6 KB +12.6 KB
crates/terrio/src/ops/xyz.rs 0 B 12.1 KB +12.1 KB
js/src/query.rs 0 B 11.5 KB +11.5 KB
crates/terrio-cli/src/cmd/pixel_info.rs 0 B 8.0 KB +8.0 KB
docs/cli.md 53.8 KB 61.3 KB +7.5 KB
crates/terrio-cli/tests/raster_query.rs 0 B 5.6 KB +5.6 KB
python/tests/test_raster_query.py 0 B 3.9 KB +3.9 KB
crates/terrio-cli/src/cmd/xyz.rs 0 B 3.4 KB +3.4 KB
crates/terrio/src/geotiff.rs 47.3 KB 50.4 KB +3.0 KB
crates/terrio-cli/src/cmd/compare.rs 0 B 2.3 KB +2.3 KB
python/python/terrio/_terrio.pyi 36.0 KB 37.7 KB +1.7 KB
scripts/conformance.py 73.9 KB 75.6 KB +1.7 KB
crates/terrio-cli/tests/mcp.rs 13.5 KB 15.2 KB +1.7 KB
js/tests/node.test.mjs 88.7 KB 90.3 KB +1.6 KB
docs/rust.md 18.5 KB 19.7 KB +1.2 KB
docs/python.md 16.3 KB 17.4 KB +1.1 KB
crates/terrio-cli/src/mcp.rs 20.9 KB 21.9 KB +1.0 KB

Comment thread crates/terrio/src/ops/pixel_info.rs Resolved
Comment thread crates/terrio/src/ops/pixel_info.rs Resolved
Comment thread crates/terrio/src/ops/pixel_info.rs Resolved
Comment thread crates/terrio/src/ops/pixel_info.rs Resolved
Comment thread crates/terrio/src/ops/compare.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I reviewed the new ops::pixel_info, ops::xyz and ops::compare modules in full or in large part. I read the GeoTIFF tag changes in the diff. I did not read the CLI, MCP, Python and JS bindings or the tests, so those are unreviewed. I did not build or run anything. Five inline comments are posted.

Bugs

  • NaN nodata is never matched in pixel_info (ops/pixel_info.rs:265). are_real_equal(NaN, NaN) is false, so float rasters with NaN nodata return Some(NaN) and NaN pixels enter interpolation. xyz.rs handles this case correctly. Confidence: medium.
  • raw_value is truncated with v as i64 for integer rasters (ops/pixel_info.rs:764). Bilinear and cubic results lose their fraction, and U64 values above i64::MAX saturate. This may differ from GDAL. Confidence: low to medium.
  • GeoJSON NaN/Infinity handling is a text replacement over the whole document (ops/pixel_info.rs:796). A text attribute containing the sentinel string would be corrupted, and unwrap_or_default() hides serialization errors. Confidence: low.

Security

  • No injection or secret-handling problems found. One thing to be aware of: compare opens subdataset names taken from file metadata as local paths. This matches GDAL's behavior. Confidence: low.

Performance

  • The block cache is bounded by count, not bytes (ops/pixel_info.rs:317). With 4096 blocks of 64×64 f64 per band, memory can exceed 1 GiB for multi-band rasters. Confidence: medium.
  • Binary comparison reads equal-sized remote files in full (ops/compare.rs:367). This conflicts with the lazy remote read guidance and should be documented or measured. Confidence: medium.

Quality

  • query() needs #[allow(clippy::too_many_arguments)]. A small options or context struct would be cleaner.
  • Several new files are very large (compare.rs is about 47 KB and pixel_info.rs about 43 KB). Splitting formatting (text, CSV, GeoJSON) from the query logic would help maintainability.

CLAUDE.md

  • NOTICE entries, docs for all surfaces, and conformance registration are present.
  • No measurement of files opened or bytes transferred for the lazy block reads or for compare is visible in the diff. AGENTS.md asks for this when I/O behavior changes.
  • The "register comparisons in scripts/conformance.py" item is met. I did not check that tolerances are reported explicitly.

Change size

Compared: the whole PR against main (merge base 7e33dd7 to PR head b379e56).

Metric Value
Files changed 32 (11 added, 21 modified, 0 removed, 0 renamed)
Size before 662.3 KB
Size after 857.3 KB
Total size change +195.0 KB
File Before After Change
crates/terrio/src/ops/compare.rs 0 B 46.1 KB +46.1 KB
crates/terrio/src/ops/pixel_info.rs 0 B 41.7 KB +41.7 KB
scripts/compare_raster_query_with_gdal.py 0 B 22.6 KB +22.6 KB
python/src/query.rs 0 B 12.6 KB +12.6 KB
js/src/query.rs 0 B 11.5 KB +11.5 KB
crates/terrio/src/ops/xyz.rs 0 B 11.4 KB +11.4 KB
crates/terrio-cli/src/cmd/pixel_info.rs 0 B 8.0 KB +8.0 KB
docs/cli.md 54.3 KB 61.7 KB +7.5 KB
crates/terrio-cli/tests/raster_query.rs 0 B 5.6 KB +5.6 KB
python/tests/test_raster_query.py 0 B 3.9 KB +3.9 KB
crates/terrio-cli/src/cmd/xyz.rs 0 B 3.4 KB +3.4 KB
crates/terrio/src/geotiff.rs 47.3 KB 50.4 KB +3.0 KB
crates/terrio-cli/src/cmd/compare.rs 0 B 2.3 KB +2.3 KB
python/python/terrio/_terrio.pyi 36.1 KB 37.8 KB +1.7 KB
scripts/conformance.py 76.8 KB 78.5 KB +1.7 KB
crates/terrio-cli/tests/mcp.rs 13.5 KB 15.2 KB +1.7 KB
js/tests/node.test.mjs 90.5 KB 92.1 KB +1.6 KB
crates/terrio-cli/src/mcp.rs 20.9 KB 22.4 KB +1.5 KB
docs/rust.md 18.5 KB 19.7 KB +1.2 KB
docs/python.md 16.3 KB 17.4 KB +1.1 KB

Comment thread crates/terrio/src/ops/xyz.rs Resolved
Comment thread crates/terrio-cli/src/cmd/compare.rs Resolved
Comment thread crates/terrio-cli/src/mcp.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

This was a partial review. I read xyz.rs (core and CLI), the CLI compare and pixel-info commands, the CLI wiring, the MCP changes and the CLI tests. I only grepped compare.rs and pixel_info.rs in crates/terrio/src/ops. I did not read the Python and JavaScript bindings, the geotiff.rs tag-reader change, the conformance script or the docs. I ran nothing.

Bugs

  • xyz data type for non-first bands (low–medium confidence): write_xyz casts values with raster.data_type(), but its comment says "first band's type". With -b 2 and mixed band types, the cast and the %d vs %g choice could differ from gdal2xyz.py. Inline comment posted.

Security

  • Nothing found. The MCP subprocess runs with null stdin, so pixel-info cannot block on or consume the MCP stream. xyz refuses to overwrite its input, and it validates options before creating the output file.

Performance

  • Nothing found in the code I read. xyz reads about 8 MiB strips aligned to blocks, and the PR description reports measured lazy-read transfer.

Quality

  • MCP failure detection by stderr text (medium): stderr_failed in crates/terrio-cli/src/mcp.rs treats any stderr line starting with terrio: , error: or a panic message as a failure. Output clipping or unrelated library text can flip the result either way. Inline comment posted.
  • Ambiguous exit status (medium): compare and pixel-info text/value output use exit status 1 for both "one difference or off-raster" and "command failed". This matches GDAL, but the user-facing docs should say so. --skip-all-optional also silently overrides the other --skip-* flags. Inline comment posted.
  • The EXIT_CODE thread-local is reset on both the success and error paths, which is correct. It is a slightly hidden channel, but acceptable.

CLAUDE.md (AGENTS.md)

  • The NOTICE attribution for the GDAL ports is present in both NOTICE files.
  • The CLI, MCP, Python, JS and docs surfaces are all added, and conformance is registered in scripts/conformance.py.
  • The PR description states known differences, such as the GDAL mask-pixel count mismatch, rather than calling them identical.

Change size

Compared: the whole PR against main (merge base 7e33dd7 to PR head 3072a01)

Metric Value
Files changed 32 (11 added, 21 modified, 0 removed, 0 renamed)
Size before 662.3 KB
Size after 857.7 KB
Total size change +195.4 KB
File Before After Change
crates/terrio/src/ops/compare.rs 0 B 46.1 KB +46.1 KB
crates/terrio/src/ops/pixel_info.rs 0 B 41.7 KB +41.7 KB
scripts/compare_raster_query_with_gdal.py 0 B 22.6 KB +22.6 KB
python/src/query.rs 0 B 12.6 KB +12.6 KB
js/src/query.rs 0 B 11.5 KB +11.5 KB
crates/terrio/src/ops/xyz.rs 0 B 11.4 KB +11.4 KB
crates/terrio-cli/src/cmd/pixel_info.rs 0 B 8.0 KB +8.0 KB
docs/cli.md 54.3 KB 62.1 KB +7.8 KB
crates/terrio-cli/tests/raster_query.rs 0 B 5.6 KB +5.6 KB
python/tests/test_raster_query.py 0 B 3.9 KB +3.9 KB
crates/terrio-cli/src/cmd/xyz.rs 0 B 3.4 KB +3.4 KB
crates/terrio/src/geotiff.rs 47.3 KB 50.4 KB +3.0 KB
crates/terrio-cli/src/cmd/compare.rs 0 B 2.3 KB +2.3 KB
python/python/terrio/_terrio.pyi 36.1 KB 37.8 KB +1.7 KB
scripts/conformance.py 76.8 KB 78.5 KB +1.7 KB
crates/terrio-cli/tests/mcp.rs 13.5 KB 15.2 KB +1.7 KB
js/tests/node.test.mjs 90.5 KB 92.1 KB +1.6 KB
crates/terrio-cli/src/mcp.rs 20.9 KB 22.4 KB +1.5 KB
docs/rust.md 18.5 KB 19.7 KB +1.2 KB
docs/python.md 16.3 KB 17.4 KB +1.1 KB

@giswqs

giswqs commented Oct 26, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai Please review the latest changes and approve this PR once your actionable findings are addressed. I am continuing to resolve the remaining review comments and CI failures.

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

@giswqs I’ll request a review of the latest changes and an approval-readiness check. Approval depends on addressing actionable findings and passing required checks. Approval is not yet confirmed.

⚠️ Action not completed

Changes approved. Review threads were not changed.


Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Comment thread crates/terrio-cli/src/mcp.rs Resolved
Comment thread crates/terrio-cli/src/cmd/pixel_info.rs Resolved
Comment thread crates/terrio/src/ops/xyz.rs Resolved
Comment thread crates/terrio/src/ops/compare.rs Resolved
Comment thread python/src/query.rs Resolved
Comment thread crates/terrio-cli/src/cmd/pixel_info.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the full diff (5,761 lines) and the core paths in compare.rs, pixel_info.rs, xyz.rs, the GeoTIFF tag reader, the MCP wrapper, and the Python and JS bindings. I did not run the build or tests, since this environment has no Bash.

Bugs

  • file_extras in compare.rs (line 254) collects TIFF tags, RPC and PAM metadata only for local paths. A local file compared with its HTTP or zip copy may therefore report false metadata differences. Confidence about 55%. I did not confirm whether remote opens already expose these items. (Inline comment posted.)
  • No other correctness defects found in the XYZ block-stepping, pixel interpolation (drag, Blocks), c_atof/tokenizer, the marker-based GeoJSON non-finite encoding, or the exit-code/MCP flow.

Security

  • No findings. Subprocess use in the conformance script is list-based with no shell. Output paths are checked against inputs before any write. The MCP output is bounded at 100 KB.

Performance

  • MCP xyz without an output file generates the full text through the pipe and discards everything past 100 KB. Confidence high that this is wasteful, low that it matters in practice.

Quality

  • The output-format dispatch (geojson/csv/text/value/json, plus the valonly alias) and the layer-by-name selection are duplicated across the CLI, Python and JS surfaces. AGENTS.md asks for bindings to stay thin. (Inline comment posted on pixel_info.rs:130.)
  • Nit: python/src/query.rs:246 lowercases format a second time. It is already lowercased at line 178. (Inline comment with a suggestion posted.)
  • Nit: the Python pixel_info type stub omits the undocumented "valonly" alias. It is harmless.

CLAUDE.md / AGENTS.md

  • NOTICE attribution, regression tests, and the conformance script registration are present.
  • ROADMAP marks the raster-query item [x]. The stated scope is compare, pixel-info and XYZ, and the PR lists its limits, so this looks acceptable. Please confirm the Tracking: parity with GDAL's unified gdal CLI commands #289 tracker stays open.

Change size

Compared: the whole PR against main (merge base 43b241c to PR head 07f4b28).

Measure Value
Files changed 33 (11 added, 22 modified, 0 removed, 0 renamed)
Size before 884.7 KB
Size after 1.09 MB
Total size change +227.8 KB
Path Before After Change
crates/terrio/src/ops/compare.rs 0 B 50.6 KB +50.6 KB
crates/terrio/src/ops/pixel_info.rs 0 B 50.1 KB +50.1 KB
scripts/compare_raster_query_with_gdal.py 0 B 24.1 KB +24.1 KB
crates/terrio/src/ops/xyz.rs 0 B 17.2 KB +17.2 KB
python/src/query.rs 0 B 15.0 KB +15.0 KB
js/src/query.rs 0 B 12.4 KB +12.4 KB
docs/cli.md 88.1 KB 97.5 KB +9.5 KB
crates/terrio-cli/src/cmd/pixel_info.rs 0 B 8.7 KB +8.7 KB
crates/terrio-cli/tests/raster_query.rs 0 B 6.3 KB +6.3 KB
python/tests/test_raster_query.py 0 B 5.6 KB +5.6 KB
crates/terrio/src/geotiff.rs 47.3 KB 51.1 KB +3.8 KB
crates/terrio-cli/src/cmd/xyz.rs 0 B 3.4 KB +3.4 KB

Sizes are file sizes from stats.json, not diff line counts. The list above shows the 12 largest of the 19 entries in largest_changes.

@giswqs

giswqs commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai approve

The latest six review threads are addressed with verified attribution, typing/docs fixes and explicit rationale. The real mask-report mismatch remains a documented difference; strict conformance intentionally reports it. Current head 05aaa76. Please approve if no functional blockers remain.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026

Copy link
Copy Markdown

@giswqs I’m requesting approval based on your update for 05aaa76e. The approval workflow will check current permissions and review readiness. Approval is not yet confirmed. This request does not resolve review threads.


🧠 Learnings used
Learnt from: CR
Repo: opengeos/terrio PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-10-24T18:29:09.016Z
Learning: Source excerpt:
# Terrio contributor instructions

## Validation

- Add a regression for a behavior change. For GDAL parity, compare real data with
  GDAL and register comparisons in `scripts/conformance.py` where applicable.
Learnt from: CR
Repo: opengeos/terrio PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-10-24T18:29:09.016Z
Learning: Source excerpt:
# Terrio contributor instructions

## Scope and architecture

- Attribute algorithm ports and copied code in the applicable `NOTICE` files.
Learnt from: CR
Repo: opengeos/terrio PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-10-24T18:29:09.016Z
Learning: Source excerpt:
# Terrio contributor instructions

## Validation

- Check values, nodata/masks, types, georeferencing and metadata as relevant.
  Report tolerances and known differences explicitly; do not describe approximate
  agreement as pixel-identical.
✅ Action performed

Changes approved. Review threads were not changed.

Comment thread python/src/query.rs Resolved
Comment thread crates/terrio/src/ops/pixel_info.rs Resolved
Comment thread crates/terrio/src/ops/xyz.rs Resolved
Comment thread crates/terrio/src/ops/compare.rs Resolved
Comment thread docs/cli.md Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

Bugs

  • No confirmed correctness bugs. I checked the compare, pixel-info and xyz logic, block and strip handling, the TIFF tag reads (16 MB cap present), the MCP exit-status change, and the Python and JS bindings against their callers. Nothing I could confirm by reading produces a wrong result.
  • Low confidence: the projected branch of write_xyz formats coordinates with Rust's {:.3}, which prints NaN/inf where %.3f prints nan/inf. It is reachable with a non-finite geotransform, which check_xyz does not reject. (xyz.rs:194)

Security

  • No issues found. Paths are only read from the user's own inputs, .aux.xml sidecars are read the same way existing info commands read them, and the in-place overwrite guards are present on the CLI, Python and MCP paths.

Performance

  • Informational, medium confidence: terrio compare with two remote URLs (binary comparison on by default) transfers both files in full when they are identical. The docs disclose this as GDAL parity, so it is a cost to note, not a defect. Use --skip-binary for remote COG comparisons.

Quality

  • High confidence: in python/src/query.rs, the else if output_format branch after the dst block is unreachable, because the check at line 182 already returns for that case. (query.rs:243)
  • Medium confidence: the public PixelInfo::to_geojson() emits NUL-prefixed strings for non-finite values, which differs from to_json() (null). Its only callers are finite-value tests. (pixel_info.rs:786)
  • Medium confidence: compare_bytes duplicates the size and "differ at the binary level" logic and wording from binary_difference. (compare.rs:197)
  • Nit: docs/cli.md has two blank lines before ## calc, and the new subcommand rows do not align with the existing column. Several docs edits also remove blank lines unrelated to this feature (docs/javascript.md, docs/testing.md).

CLAUDE.md / AGENTS.md

  • Attribution for the ported GDAL code is present in both NOTICE files. Options are exposed on the CLI, Python, JS and MCP surfaces. Regression tests are included. I/O cost was measured and documented.
  • I did not run the build or tests. I have no execution tool here, so compile and test results are not verified by this review.

Change size

Compared: the whole PR against main (merge base 43b241c to PR head 05aaa76).

Measure Value
Files changed 33 (added 11, modified 22, removed 0, renamed 0)
Size before 883.8 KB
Size after 1.09 MB
Total size change +228.9 KB
Path Before After Change
crates/terrio/src/ops/compare.rs 0 B 50.6 KB +50.6 KB
crates/terrio/src/ops/pixel_info.rs 0 B 50.1 KB +50.1 KB
scripts/compare_raster_query_with_gdal.py 0 B 24.1 KB +24.1 KB
crates/terrio/src/ops/xyz.rs 0 B 17.2 KB +17.2 KB
python/src/query.rs 0 B 15.0 KB +15.0 KB
js/src/query.rs 0 B 12.4 KB +12.4 KB
docs/cli.md 88.1 KB 97.5 KB +9.4 KB
crates/terrio-cli/src/cmd/pixel_info.rs 0 B 8.7 KB +8.7 KB
crates/terrio-cli/tests/raster_query.rs 0 B 6.3 KB +6.3 KB
python/tests/test_raster_query.py 0 B 5.6 KB +5.6 KB
crates/terrio/src/geotiff.rs 47.3 KB 51.1 KB +3.8 KB
crates/terrio-cli/src/cmd/xyz.rs 0 B 3.4 KB +3.4 KB
js/tests/node.test.mjs 102.3 KB 104.8 KB +2.5 KB
crates/terrio-cli/src/cmd/compare.rs 0 B 2.4 KB +2.4 KB
python/python/terrio/_terrio.pyi 45.0 KB 46.8 KB +1.8 KB
scripts/conformance.py 85.2 KB 86.9 KB +1.7 KB
crates/terrio-cli/tests/mcp.rs 18.5 KB 20.2 KB +1.7 KB
docs/testing.md 49.8 KB 51.5 KB +1.6 KB
docs/python.md 21.8 KB 23.4 KB +1.6 KB
docs/javascript.md 19.3 KB 20.7 KB +1.5 KB

@giswqs

giswqs commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai approve

The latest eight review threads are addressed with verified attribution, typing/docs fixes and explicit rationale. The real mask-report mismatch remains a documented difference; strict conformance intentionally reports it. Current head 6a244d9. Please approve if no functional blockers remain.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026

Copy link
Copy Markdown

@giswqs I’m requesting approval based on your update for 6a244d91. The approval workflow will check current permissions and review readiness. Approval is not yet confirmed. This request does not resolve review threads.


🧠 Learnings used
Learnt from: CR
Repo: opengeos/terrio PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-10-24T18:29:09.016Z
Learning: Source excerpt:
# Terrio contributor instructions

## Validation

- Add a regression for a behavior change. For GDAL parity, compare real data with
  GDAL and register comparisons in `scripts/conformance.py` where applicable.
Learnt from: CR
Repo: opengeos/terrio PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-10-24T18:29:09.016Z
Learning: Source excerpt:
# Terrio contributor instructions

## Scope and architecture

- Attribute algorithm ports and copied code in the applicable `NOTICE` files.
Learnt from: CR
Repo: opengeos/terrio PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-10-24T18:29:09.016Z
Learning: Source excerpt:
# Terrio contributor instructions

## Validation

- Check values, nodata/masks, types, georeferencing and metadata as relevant.
  Report tolerances and known differences explicitly; do not describe approximate
  agreement as pixel-identical.
Learnt from: giswqs
Repo: opengeos/terrio PR: 303
File: scripts/conformance.py:687-691
Timestamp: 2026-10-27T02:10:51.874Z
Learning: Within repository "opengeos/terrio", only for files matching one of ["scripts/conformance.py"]: When reviewing result classification or strict-mode handling in scripts/conformance.py, preserve DIFFERS for real known differences, including documented raster-query mask-report differences. Do not recommend relabeling these cases as identical or within tolerance, or silently excluding them from --strict failures, merely because the differences are documented. Any expected-difference exemption must require explicit user selection and preserve the reported difference.
✅ Action performed

Changes approved. Review threads were not changed.

Comment thread crates/terrio-cli/src/cmd/pixel_info.rs Resolved
Comment thread python/src/query.rs Resolved
Comment thread crates/terrio-cli/src/cmd/xyz.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the full diff (33 files) and the surrounding sources for compare, pixel-info, xyz, the MCP exit-code path, and the Python and JS bindings. I found no correctness bugs I could confirm by reading. The main concern is duplicated logic that AGENTS.md asks bindings to avoid. I could not build or run the tests here.

Bugs

  • None confirmed. I checked the strip and block jump logic in xyz.rs, the bilinear and cubic edge handling (drag, out_of_border) in pixel_info.rs, data_type_union, the RATIONAL/RESOLUTION tag parsing in geotiff.rs, the centroids ordering that pixel_info_layer zips against, and the tokenizer and c_atof loops. None showed a defect. Confidence in this result: moderate, since I did not execute anything.

Security

  • None found. Scripts use list-form subprocess.run with no shell. Output paths are checked against inputs in CLI, Python and JS. JSON non-finite markers are chosen to avoid collisions with user strings.

Performance

  • Low: xyz.rs allocates a String per value through fmt_g, and json_to_python in python/src/query.rs serializes and re-parses the whole result. Both are fine for typical sizes but matter for very large exports.

Quality

  • Medium, about 80–85% confidence: the resampling validation, the compare skip-flag mapping and the XYZ band default are each repeated across the CLI, Python and JS (inline comments posted on pixel_info.rs:84, python/src/query.rs:80 and xyz.rs:54).
  • Nit: docs/javascript.md and docs/testing.md contain unrelated blank-line deletions, and docs/javascript.md gains a double blank line before "Pixel-wise operations".
  • Nit: _terrio.pyi lists format values without "valonly", which the runtime accepts.
  • Nit: CLI exit status 1 (and 2) is shared between query results and errors. This is documented and matches GDAL, but a script cannot tell one difference from a failure without reading stderr.

CLAUDE.md

  • Low, about 50%: mcp.rs READ_ONLY omits pixel-info and xyz, so they are annotated destructiveHint. Both are read-only when no output file is given.
  • The NOTICE attributions, validation evidence, roadmap and conformance registration look consistent with AGENTS.md.

Change size

Compared: the whole PR against main (merge base 43b241c to PR head 6a244d9).

Metric Value
Files changed 33 (11 added, 22 modified, 0 removed, 0 renamed)
Size before 904.9 KB
Size after 1.09 MB
Total size change +237.1 KB
Path Before After Change
crates/terrio/src/ops/pixel_info.rs 0 B 52.0 KB +52.0 KB
crates/terrio/src/ops/compare.rs 0 B 51.8 KB +51.8 KB
scripts/compare_raster_query_with_gdal.py 0 B 24.6 KB +24.6 KB
crates/terrio/src/ops/xyz.rs 0 B 19.2 KB +19.2 KB
python/src/query.rs 0 B 15.2 KB +15.2 KB
js/src/query.rs 0 B 12.7 KB +12.7 KB
docs/cli.md 90.1 KB 100.2 KB +10.1 KB
crates/terrio-cli/src/cmd/pixel_info.rs 0 B 8.7 KB +8.7 KB
crates/terrio-cli/tests/raster_query.rs 0 B 6.3 KB +6.3 KB
python/tests/test_raster_query.py 0 B 5.6 KB +5.6 KB

The table lists the top 10 of 19 entries in largest_changes. trees_truncated is false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant