Repository: SciTools/cartopy

Issue:
.add_image very poor quality
### Description
<!-- Please provide a general introduction to the issue/proposal. -->
The .add_image command provides a map at very low quality. Can it be improved?
![example_Stamen](https://user-images.githubusercontent.com/24934125/82161111-f9644780-9891-11ea-9824-e456540d8e12.png)

Similar to post #1048 which has been closed -- the solution there is to add `interpolation='spline36', regrid_shape=2000` as args in `.add_image()` but this does not work any more.
<!--
If you are reporting a bug, attach the *entire* traceback from Python.

If you are proposing an enhancement/new feature, provide links to related articles, reference examples, etc.

If you are asking a question, please ask on StackOverflow and use the cartopy tag. All cartopy
questions on StackOverflow can be found at https://stackoverflow.com/questions/tagged/cartopy
-->

#### Code to reproduce

```
import matplotlib.pyplot as plt
import cartopy
import cartopy.io.img_tiles as cimgt

# Setting projection and ploting the second tilt
projection = ccrs.LambertConformal(central_latitude=39.3,
                                   central_longitude=-101.7)


fig = plt.figure(figsize=(20,20))
ax = fig.add_subplot(1, 1, 1, projection=projection)
ax.set_extent((-104.7, -98.7, 36.3, 42.3))

# Map features
ax.add_image(cimgt.Stamen('toner'), 8)

plt.savefig("example.png", format='png', bbox_inches="tight", dpi=500)

plt.show()
```

#### Traceback 

```

```

<details>
 <summary>Full environment definition</summary>

<!-- fill in the following information as appropriate -->
![example_OSM](https://user-images.githubusercontent.com/24934125/82161099-ea7d9500-9891-11ea-964c-5f27834b353f.png)
![example_Stamen](https://user-images.githubusercontent.com/24934125/82161101-ecdfef00-9891-11ea-9923-59929e412bb1.png)

### Operating system


### Cartopy version


### conda list

```
```

### pip list

```
```

</details>

.add_image very poor quality
### Description
<!-- Please provide a general introduction to the issue/proposal. -->
The .add_image command provides a map at very low quality. Can it be improved?
![example_Stamen](https://user-images.githubusercontent.com/24934125/82161111-f9644780-9891-11ea-9824-e456540d8e12.png)

Similar to post #1048 which has been closed -- the solution there is to add `interpolation='spline36', regrid_shape=2000` as args in `.add_image()` but this does not work any more.
<!--
If you are reporting a bug, attach the *entire* traceback from Python.

If you are proposing an enhancement/new feature, provide links to related articles, reference examples, etc.

If you are asking a question, please ask on StackOverflow and use the cartopy tag. All cartopy
questions on StackOverflow can be found at https://stackoverflow.com/questions/tagged/cartopy
-->

#### Code to reproduce

```
import matplotlib.pyplot as plt
import cartopy
import cartopy.io.img_tiles as cimgt

# Setting projection and ploting the second tilt
projection = ccrs.LambertConformal(central_latitude=39.3,
                                   central_longitude=-101.7)


fig = plt.figure(figsize=(20,20))
ax = fig.add_subplot(1, 1, 1, projection=projection)
ax.set_extent((-104.7, -98.7, 36.3, 42.3))

# Map features
ax.add_image(cimgt.Stamen('toner'), 8)

plt.savefig("example.png", format='png', bbox_inches="tight", dpi=500)

plt.show()
```

#### Traceback 

```

```

<details>
 <summary>Full environment definition</summary>

<!-- fill in the following information as appropriate -->
![example_OSM](https://user-images.githubusercontent.com/24934125/82161099-ea7d9500-9891-11ea-964c-5f27834b353f.png)
![example_Stamen](https://user-images.githubusercontent.com/24934125/82161101-ecdfef00-9891-11ea-9923-59929e412bb1.png)

### Operating system


### Cartopy version


### conda list

```
```

### pip list

```
```

</details>



Discussion:
+1

same problem here:

used to add `interpolation='spline36'` to `add_image` function in cartopy 0.17 but does not work anymore after upgrading to 0.18.

removing the option makes all my maps look just awful :-(

had a look in documentation and source code for both 0.17 and 0.18 `add_image` functions and they are just identical so there must be some not-trivial-to-spot change involved


I have downgraded to `0.17` to get acceptable results. I still feel like the quality could be pushed more. `interpolation='spline36` doesn't change much at all, the `regrid_shape=2000` changed to `500`, `10000` does make a huge difference.

I should add I am using this code to make maps for a video with GPS and radar data overlaid (storm chasing), so it would be great to be able to zoom in and still have decent quality. Just needs a little bit more, I feel. I will work on programming an adjusting zoom in the meantime to animate a series of maps.
thank you very much for your hint @Benblob688 ! i did not know of the `regrid_shape` option's impact on image quality!

Still, this issue is about a bug or at least an undocumented change in cartopy 0.18.

let's wait from some dev to come up with a fix, a workaround or at least an explanation ;-)


Hi @Benblob688 and @fanfani. Thanks for reporting this. Passing the regrid_shape and interpolation arguments has become broken due to a tiny mistake in Cartopy's Geoaxes.draw method. I will propose a fix very shortly. 
+1

same problem here:

used to add `interpolation='spline36'` to `add_image` function in cartopy 0.17 but does not work anymore after upgrading to 0.18.

removing the option makes all my maps look just awful :-(

had a look in documentation and source code for both 0.17 and 0.18 `add_image` functions and they are just identical so there must be some not-trivial-to-spot change involved


I have downgraded to `0.17` to get acceptable results. I still feel like the quality could be pushed more. `interpolation='spline36` doesn't change much at all, the `regrid_shape=2000` changed to `500`, `10000` does make a huge difference.

I should add I am using this code to make maps for a video with GPS and radar data overlaid (storm chasing), so it would be great to be able to zoom in and still have decent quality. Just needs a little bit more, I feel. I will work on programming an adjusting zoom in the meantime to animate a series of maps.
thank you very much for your hint @Benblob688 ! i did not know of the `regrid_shape` option's impact on image quality!

Still, this issue is about a bug or at least an undocumented change in cartopy 0.18.

let's wait from some dev to come up with a fix, a workaround or at least an explanation ;-)


Hi @Benblob688 and @fanfani. Thanks for reporting this. Passing the regrid_shape and interpolation arguments has become broken due to a tiny mistake in Cartopy's Geoaxes.draw method. I will propose a fix very shortly. 

Resolving patch:
diff --git a/lib/cartopy/mpl/geoaxes.py b/lib/cartopy/mpl/geoaxes.py
--- a/lib/cartopy/mpl/geoaxes.py
+++ b/lib/cartopy/mpl/geoaxes.py
@@ -469,11 +469,12 @@ def draw(self, renderer=None, **kwargs):
         #       caching the resulting image;
         #       buffering the result by 10%...;
         if not self._done_img_factory:
-            for factory, args, kwargs in self.img_factories:
+            for factory, factory_args, factory_kwargs in self.img_factories:
                 img, extent, origin = factory.image_for_domain(
-                    self._get_extent_geom(factory.crs), args[0])
+                    self._get_extent_geom(factory.crs), factory_args[0])
                 self.imshow(img, extent=extent, origin=origin,
-                            transform=factory.crs, *args[1:], **kwargs)
+                            transform=factory.crs, *factory_args[1:],
+                            **factory_kwargs)
         self._done_img_factory = True
 
         return matplotlib.axes.Axes.draw(self, renderer=renderer, **kwargs)


Test patch: