Skip to content

Commit

Permalink
fixing shift_xy
Browse files Browse the repository at this point in the history
  • Loading branch information
gregory-halverson committed Nov 22, 2024
1 parent b2a28de commit 0aa61ec
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions rasters/raster_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,10 +537,16 @@ def subset(self, target: Union[Window, Point, Polygon, BBox, RasterGeometry]) ->
return subset

def shift_xy(self, x_shift: float, y_shift: float) -> RasterGrid:
new_affine = self.affine * Affine.translation(x_shift, y_shift)
grid = RasterGrid.from_affine(new_affine, self.rows, self.cols, self.crs)

return grid
cell_width = self.cell_width
cell_height = self.cell_height
x_origin = self.x_origin + x_shift
y_origin = self.y_origin + y_shift
shifted_x_origin = x_origin + x_shift
shifted_y_origin = y_origin + y_shift
shifted_affine = Affine(cell_width, 0, shifted_x_origin, 0, cell_height, shifted_y_origin)
shifted_grid = RasterGrid.from_affine(shifted_affine, self.rows, self.cols, self.crs)

return shifted_grid

def shift_distance(self, distance: float, direction: float) -> RasterGrid:
x_shift = distance * np.cos(np.radians(direction))
Expand Down

0 comments on commit 0aa61ec

Please sign in to comment.