Skip to content

Conversation

@jesspav
Copy link
Collaborator

@jesspav jesspav commented Dec 5, 2025

Adding functions RS_WorldToRasterCoordX, RS_WorldToRasterCoordY, RS_WorldToRasterCoord, with a provided x and y coordinate.

Note that we should have another variant of these that accept a point, but it is out of scope for this PR.

Examples:

> select rs_worldtorastercoord(RS_Example(), 45.08, 80.07 );
┌───────────────────────────────────────────────────────────────────┐
│ rs_worldtorastercoord(rs_example(),Float64(45.08),Float64(80.07)) │
│                              geometry                             │
╞═══════════════════════════════════════════════════════════════════╡
│ POINT(1 0)                                                        │
└───────────────────────────────────────────────────────────────────┘


> select rs_worldtorastercoordx(RS_Example(), 45.08, 80.07 );
┌────────────────────────────────────────────────────────────────────┐
│ rs_worldtorastercoordx(rs_example(),Float64(45.08),Float64(80.07)) │
│                                int64                               │
╞════════════════════════════════════════════════════════════════════╡
│                                                                  1 │
└────────────────────────────────────────────────────────────────────┘

> select rs_worldtorastercoordy(RS_Example(), 45.08, 80.07 );
┌────────────────────────────────────────────────────────────────────┐
│ rs_worldtorastercoordy(rs_example(),Float64(45.08),Float64(80.07)) │
│                                int64                               │
╞════════════════════════════════════════════════════════════════════╡
│                                                                  0 │
└────────────────────────────────────────────────────────────────────┘

Benches:

native-raster-rs_worldtorastercoord-ArrayScalarScalar(Raster(64, 64), Float64(-45.0, 45.0), Float64(...
                        time:   [1.3438 ms 1.3456 ms 1.3473 ms]

native-raster-rs_worldtorastercoordx-ArrayScalarScalar(Raster(64, 64), Float64(-45.0, 45.0), Float64...
                        time:   [1.1348 ms 1.1367 ms 1.1386 ms]

native-raster-rs_worldtorastercoordy-ArrayScalarScalar(Raster(64, 64), Float64(-45.0, 45.0), Float64...
                        time:   [1.1326 ms 1.1344 ms 1.1361 ms]


@jesspav jesspav requested a review from Copilot December 5, 2025 21:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds three new functions for converting world coordinates to raster pixel coordinates: RS_WorldToRasterCoordX, RS_WorldToRasterCoordY, and RS_WorldToRasterCoord. These functions perform the inverse affine transformation of the existing world coordinate functions.

Key Changes:

  • Implements inverse affine transformation logic with determinant validation
  • Adds three new UDFs for raster coordinate conversion
  • Updates test infrastructure to support CRS in generated test rasters

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
rust/sedona-raster/src/affine_transformation.rs Adds to_raster_coordinate function implementing inverse affine transformation with tests
rust/sedona-raster-functions/src/rs_rastercoordinate.rs New file implementing the three world-to-raster coordinate UDFs
rust/sedona-raster-functions/src/register.rs Registers the new UDFs in the default function set
rust/sedona-raster-functions/src/lib.rs Adds module declaration for rs_rastercoordinate
rust/sedona-testing/src/rasters.rs Updates test raster generation to include CRS
rust/sedona-raster-functions/benches/native-raster-functions.rs Adds benchmarks for the new functions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jesspav jesspav marked this pull request as ready for review December 6, 2025 00:23
Copy link
Member

@paleolimbot paleolimbot left a comment

Choose a reason for hiding this comment

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

Thank you!

@paleolimbot paleolimbot merged commit 257bc8f into apache:main Dec 8, 2025
14 checks passed
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.

2 participants