Skip to content

feat: add origin property and set_origin() method - #443

Merged
nathanjmcdougall merged 3 commits into
developfrom
442-feature-request-shift_bounds-translate_bounds-method-for-longitude-wrapping
May 20, 2026
Merged

feat: add origin property and set_origin() method#443
nathanjmcdougall merged 3 commits into
developfrom
442-feature-request-shift_bounds-translate_bounds-method-for-longitude-wrapping

Conversation

@nathanjmcdougall

@nathanjmcdougall nathanjmcdougall commented May 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds Raster.origin property (getter + setter) and Raster.set_origin(*, x=None, y=None) immutable method to adjust the affine transform origin without modifying pixel data.

Motivation

When working with ShakeMap rasters near the antimeridian, some source rasters arrive with non-standard longitude conventions (e.g. bounds from -200 to -170). This causes spatial operations like to_bounds() to produce all-NaN output due to no overlap with standard EPSG:4326 bounds.

Usage

# Fix non-standard longitude
if raster.bounds.xmin < -180:
    raster = raster.set_origin(x=raster.origin[0] + 360)

Changes

  • Raster.origin property (getter): returns (transform.c, transform.f)
  • Raster.origin setter: mutates transform translation in place (notebook/interactive use)
  • Raster.set_origin(*, x=None, y=None): returns new Raster with updated origin (pipeline use)
  • 11 tests covering getter, setter, immutability, and the longitude wrapping use case
  • Design spec at docs/specs/2025-05-20-set-origin-design.md

Closes #442

…lation

Add Raster.origin property (getter + setter) and Raster.set_origin()
immutable method to adjust the affine transform origin without modifying
pixel data. This enables normalizing non-standard longitude conventions
(e.g. -200 to -170 -> 160 to 190) before spatial operations.

Closes #442

@b-j-karl b-j-karl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

approved once spec is clarified

@t-t-sonarqube

t-t-sonarqube Bot commented May 19, 2026

Copy link
Copy Markdown

@nathanjmcdougall
nathanjmcdougall merged commit a3e66f3 into develop May 20, 2026
15 checks passed
@nathanjmcdougall
nathanjmcdougall deleted the 442-feature-request-shift_bounds-translate_bounds-method-for-longitude-wrapping branch May 20, 2026 00:00
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.

Feature request: shift_bounds / translate_bounds method for longitude wrapping

2 participants