Skip to content

Commit

Permalink
Merge pull request python-rasters#31 from gregory-halverson/main
Browse files Browse the repository at this point in the history
fixing `shift_xy`
  • Loading branch information
gregory-halverson authored Nov 22, 2024
2 parents 6d50351 + 9f449ae commit 4b287ad
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "rasters"
version = "1.4.1"
version = "1.4.2"
description = "raster processing toolkit"
readme = "README.md"
authors = [
Expand Down
14 changes: 4 additions & 10 deletions rasters/raster_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,16 +537,10 @@ def subset(self, target: Union[Window, Point, Polygon, BBox, RasterGeometry]) ->
return subset

def shift_xy(self, x_shift: float, y_shift: float) -> RasterGrid:
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
new_affine = self.affine * Affine.translation(x_shift / self.cell_size, y_shift / self.cell_size)
grid = RasterGrid.from_affine(new_affine, self.rows, self.cols, self.crs)

return grid

def shift_distance(self, distance: float, direction: float) -> RasterGrid:
x_shift = distance * np.cos(np.radians(direction))
Expand Down
2 changes: 1 addition & 1 deletion rasters/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.1
1.4.2

0 comments on commit 4b287ad

Please sign in to comment.