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

Fixing a problem with lost resolution in imshow #1645

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
16 changes: 15 additions & 1 deletion lib/cartopy/mpl/geoaxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,21 @@ def imshow(self, img, *args, **kwargs):
raise ValueError('Expected a projection subclass. Cannot '
'handle a %s in imshow.' % type(transform))

target_extent = self.get_extent(self.projection)
# |target_extent| is the area the image will cover in
# target projection coordinates. This affects the
# resolution of the rescaled image.
if extent is None:
# This assumes it will cover the current visible area.
target_extent = self.get_extent(self.projection)
else:
box = sgeom.box(extent[0], extent[2], extent[1], extent[3])
target_geometry = transform.project_geometry(box,
self.projection)
target_extent = (target_geometry.bounds[0],
target_geometry.bounds[2],
target_geometry.bounds[1],
target_geometry.bounds[3])

regrid_shape = kwargs.pop('regrid_shape', 750)
regrid_shape = self._regrid_shape_aspect(regrid_shape,
target_extent)
Expand Down