Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue #409 and #407 #410

Merged
merged 5 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions geoutils/raster/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -2100,7 +2100,7 @@ def reproject(
(dst_transform == self.transform) or (dst_transform is None),
(dst_crs == self.crs) or (dst_crs is None),
(dst_size == self.shape[::-1]) or (dst_size is None),
np.all(dst_res == self.res) or (dst_res == self.res[0] == self.res[1]) or (dst_res is None),
np.all(np.array(dst_res) == self.res) or (dst_res is None),
]
):
if (dst_nodata == self.nodata) or (dst_nodata is None):
Expand Down Expand Up @@ -2514,12 +2514,7 @@ def show(

# Create axes
if ax is None:
# If no figure exists, get a new axis
if len(plt.get_fignums()) == 0:
ax0 = plt.gca()
# Otherwise, get first axis
else:
ax0 = plt.gcf().axes[0]
ax0 = plt.gca()
elif isinstance(ax, str) and ax.lower() == "new":
_, ax0 = plt.subplots()
elif isinstance(ax, matplotlib.axes.Axes):
Expand Down
17 changes: 17 additions & 0 deletions tests/test_raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -2147,6 +2147,23 @@ def test_show(self) -> None:
img_RGB = gu.Raster(self.landsat_rgb_path)

# Test default plot
img.show()
if DO_PLOT:
plt.show()
else:
plt.close()
assert True

# Test with new figure
plt.figure()
img.show()
if DO_PLOT:
plt.show()
else:
plt.close()
assert True

# Test with provided ax
ax = plt.subplot(111)
img.show(ax=ax, title="Simple plotting test")
if DO_PLOT:
Expand Down
Loading