Reconciling transforms by from_origin and from_bounds


ayr035@...
 

I am trying to reconcile the transforms that I get by using transform.from_origin and transform.from_bounds

bounds = BoundingBox(left=1679712.0, bottom=5860848.0, right=1862208.0, top=6029312.0)
width = math.ceil((bounds.right - bounds.left) / 100) # resolution of 100
height = math.ceil((bounds.bottom - bounds.top) / 100)
# resolution of 100

T_o = transform.from_origin(bounds.left, bounds.top, width, height)
Affine(1825.0, 0.0, 1679712.0,
      0.0, -1685.0, 6029312.0)

T_b = transform.from_bounds(*bounds, width, height)
Affine(99.99780821917808, 0.0, 1679712.0,
      0.0, -99.9786350148368, 6029312.0)

The transforms seem to differ quite significantly. If we compute the array bounds, I expect to recover the original bounds
transform.array_bounds(height, width, T_o) ->
(1679712.0, 3190087.0, 5010337.0, 6029312.0)   # bottom and right bounds are wrong?
transform.array_bounds(height, width, T_b) -> (
1679712.0, 5860848.0, 1862208.0, 6029312.0)   # These are my original bounds

Am I misusing transform.from_origin?

Join main@rasterio.groups.io to automatically receive all group messages.