File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -900,13 +900,17 @@ def _prepare_affine_storage(
900900 cos_a , sin_a = np .cos (rad ), np .sin (rad )
901901
902902 # Create output coordinate grids
903- # For each output pixel, find corresponding input pixel
903+ # For each output pixel (row, col), find corresponding geo coordinate
904904 out_rows , out_cols = np .mgrid [0 :out_height , 0 :out_width ]
905905
906906 # Transform output pixels to geo coordinates
907- # Output image: origin at polygon origin, rotated by angle
908- geo_x = origin_x + out_cols * pixel_size_x * cos_a - out_rows * pixel_size_y * sin_a
909- geo_y = origin_y + out_cols * pixel_size_x * sin_a + out_rows * pixel_size_y * cos_a
907+ # Note: In GeoTiff, rows increase downward but geo Y increases upward
908+ # So we need to go along the rectangle edges:
909+ # - Column direction: along first edge (angle direction)
910+ # - Row direction: perpendicular to first edge (angle + 90 degrees)
911+ # For row, we subtract because row 0 is at origin (top of rectangle in geo)
912+ geo_x = origin_x + out_cols * pixel_size_x * cos_a + out_rows * pixel_size_y * sin_a
913+ geo_y = origin_y + out_cols * pixel_size_x * sin_a - out_rows * pixel_size_y * cos_a
910914
911915 # Transform geo coordinates to input pixel coordinates
912916 inv_transform = ~ old_transform
You can’t perform that action at this time.
0 commit comments