Skip to content
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

Transform decomposition #2586

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

Transform decomposition #2586

wants to merge 8 commits into from

Conversation

groutr
Copy link
Contributor

@groutr groutr commented Sep 6, 2022

A useful utility function for decomposing a conformal transform into its translation, rotation, and scale parameters.

from rasterio.transform import decompose
# transform = Affine.translation(1, 3) * Affine.scale(3, 3) * Affine.rotation(45)
decompose(transform)
# ((1.0, 3.0), 44.999999999999986, (3.0, 3.0))

@snowman2
Copy link
Member

I am wondering if this makes more sense here?
https://github.com/rasterio/affine/

@groutr
Copy link
Contributor Author

groutr commented Nov 30, 2022

This PR could make more sense for affine if the following two things can be resolved.

  1. In its current state this would add a numpy dependency to affine (which affine seems to be trying to avoid external dependencies). Affine seems to do a similar decomposition, but only depends on the standard library. I'm not sure how robust affine's calculation is regarding floating point issues.
  2. Affine does have methods to extract translation, rotation (rotation_angle), and scale (scale_factor) but will return those values whether the transform is conformal or not. This implementation limits decomposition to conformal transforms. Checking for conformity in affine could potentially break compatibility in affine. It could be added as a new method perhaps where conformity is checked.

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.

None yet

2 participants