Improving images added to Cartopy figures

metadata

Today, I just had a Pull Request approved in Cartopy. This PR added **kwargs to the .background_img() method to be passed down the call stack to Cartopy’s .imshow() method. Why is this important? When drawing images in a figure, Cartopy:

  1. merges all tiles together (if applicable);
  2. warps the image to the figure’s projection;
  3. scales the image (to 750 px × 750 px by default); and
  4. passes the (merged and) warped and scaled image to MatPlotLib’s .imshow() method.

The penultimate step of scaling the image to 750 px × 750 px is able to be overridden when using the .add_image() method, the .stock_img() method and Cartopy’s .imshow() method directly - but it was not available when using the .background_img() method. It should also be noted that Cartopy’s .imshow() method itself uses **kwargs and it passes them to MatPlotLib’s .imshow() method behind the scenes. This means that MatPlotLib keyword arguments, such as interpolation and resample, can also be passed.