feat(sedona-functions): add raster display support to SD_Format#591
feat(sedona-functions): add raster display support to SD_Format#591Kontinuation wants to merge 2 commits intoapache:mainfrom
Conversation
Add raster formatting to SD_Format, displaying raster metadata (dimensions, geotransform, band count, outdb status) as a human-readable string instead of erroring on raster types.
1a373db to
f810dea
Compare
There was a problem hiding this comment.
Pull request overview
This pull request adds raster formatting support to the SD_Format function, enabling raster types to be displayed as human-readable strings. Previously, SD_Format returned an error when encountering raster types. Now it produces formatted output showing key metadata such as dimensions, geotransform parameters, band count, and OutDb status.
Changes:
- Modified
SD_Formatto support raster types by adding a newraster_value_to_formatted_valuefunction - Updated type conversion logic to map raster types to UTF8 output instead of returning an error
- Added
sedona-rasterdependency tosedona-functions
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| rust/sedona-functions/src/sd_format.rs | Adds raster formatting logic with metadata display and width_hint support |
| rust/sedona-functions/Cargo.toml | Adds sedona-raster workspace dependency |
| Cargo.lock | Updates lock file with sedona-raster dependency for sedona-functions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
94bd826 to
88f92b2
Compare
| fn raster_value_to_formatted_value( | ||
| columnar_value: &ColumnarValue, | ||
| maybe_width_hint: Option<usize>, | ||
| ) -> Result<ColumnarValue> { | ||
| match columnar_value { |
There was a problem hiding this comment.
The logic for displaying individual raster items should probably live in sedona-raster
| let _ = write!( | ||
| limited_output, | ||
| "Raster[w={}, h={}, ul=({:.6}, {:.6}), scale=({:.6}, {:.6}), skew=({:.6}, {:.6}), bands={}, outdb={}]", | ||
| metadata.width(), | ||
| metadata.height(), | ||
| metadata.upper_left_x(), | ||
| metadata.upper_left_y(), | ||
| metadata.scale_x(), | ||
| metadata.scale_y(), | ||
| metadata.skew_x(), | ||
| metadata.skew_y(), | ||
| bands.len(), | ||
| has_outdb_band | ||
| ); |
There was a problem hiding this comment.
At least for rasters that are not rotated or skewed, what I would really like to know are the bounds and CRS. Can this output be more like:
[WxH/nbands] @ [xmin ymin xmax ymax] / crs <outdb>
That may be a little more compact. Even for skewed data the 2D bounds are probably more useful output for human reading.
(Drawing from the last time I had to decide this: https://paleolimbot.github.io/wk/reference/grd.html )
Summary
SD_Format, displaying raster metadata (dimensions, geotransform, band count, outdb status) as a human-readable stringSD_Formatreturned an error for raster types; now it produces output like:Raster[w=1, h=2, ul=(1.000000, 2.000000), scale=(0.000000, -0.000000), skew=(0.000000, 0.000000), bands=1, outdb=false]width_hintoption for truncationsedona-rasterdependency tosedona-functionsExample