rasterio / affine

Affine transformation matrices
BSD 3-Clause "New" or "Revised" License
156 stars 28 forks source link

Floating Point Issue and Affine #83

Closed cmarshak closed 1 year ago

cmarshak commented 1 year ago

Not charactizing affine transformation correctly. Sorry. Closed.


Hi Affine team,

Very much enjoy using this library via rasterio.

I am pretty sure this is purely a floating point issue, but wanted to post to get clarity. Works as expected!

In [1]: from affine import Affine

In [2]: t = Affine(0.00041666666666666664, 0.0 , -181.00020833333335, 0.0, -0.0002777777777777778, 51.75013888888889)

In [3]: t * (.5, .5)
Out[3]: (-181.0, 51.75)

In [4]: -181.00020833333335 + 0.00041666666666666664 * .5
Out[4]: -180.0

In [5]: 51.75013888888889 - 0.0002777777777777778 * .5
Out[5]: 51.75

It appears the transform is rounding to 4 digits.

sgillies commented 1 year ago

@cmarshak I'm not sure where you're seeing the discrepancy. Is it at 3, 4, or 5?

cmarshak commented 1 year ago

My bad - should be .5 in [4] and [5] - I will change.