title: Inscribing a smaller domain onto a cartopy map in Python
body: <p>I've been working to make a visual for a poster regarding the physical domain that I am studying. I'm working with a nested domain, so I have 1 smaller domain inside a larger outer domain. I'm trying to create a cartopy plot that shows both the outer domain and inner domain. Ideally, the result would look something like this:<a href="https://i.stack.imgur.com/lpP9M.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lpP9M.jpg" alt="Inner domain in an outer domain." /></a></p>
  <p>I'm really struggling with trying to get my smaller domain inscribed onto my map. I've attempted to make a Shapely LinearRing to show the inner domain, but it is not working. Here's the code I have created so far:</p>
  <pre><code># Imports
  import numpy as np
  import sys, os
  import matplotlib.pyplot as plt
  %matplotlib inline
  import netCDF4
  from netCDF4 import Dataset
  from matplotlib.cm import get_cmap
  import cartopy.crs as ccrs
  import cartopy.feature as cfeature
  from cartopy.feature import NaturalEarthFeature, COLORS
  import metpy as mp
  import metpy.calc as mpcalc
  from metpy.calc import divergence, smooth_gaussian
  from metpy.units import units
  import xarray as xr
  from wrf import getvar, interplevel, to_np, latlon_coords, get_cartopy, cartopy_xlim, cartopy_ylim, ALL_TIMES
  from shapely.geometry.polygon import LinearRing
  from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter
  from shapely import geometry
  
  # Get 1km lats/lons
  lats1km = getvar(ds1, 'lat')
  lons1km = getvar(ds1, 'lon')
  lat1km_max = to_np(np.max(lats1km))
  lat1km_min = to_np(np.min(lats1km))
  lon1km_max = to_np(np.max(lons1km))
  lon1km_min = to_np(np.min(lons1km))
  
  # Get 3km lats/lons
  lats3km = getvar(ds3, 'lat')
  lons3km = getvar(ds3, 'lon')
  lat3km_max = to_np(np.max(lats3km))
  lat3km_min = to_np(np.min(lats3km))
  lon3km_max = to_np(np.max(lons3km))
  lon3km_min = to_np(np.min(lons3km))
  
  domain = [lon3km_min, lat3km_min, lon3km_max, lat3km_max]
  lons = [lat1km_min, lat1km_min, lat1km_max, lat1km_max]
  lats = [lon1km_min, lon1km_max, lon1km_max, lon1km_min]
  ring = LinearRing(list(zip(lons, lats)))
  geom = geometry.box(minx=lon1km_min, miny=lat1km_min, maxx=lon1km_max, maxy=lat1km_max)
  
  # Grab CRS
  crs = get_cartopy(wrfin=ds1)
  
  # Create figure and axes
  fig = plt.figure(figsize=(20,10))
  ax0 = fig.add_subplot(1, 1, 1, projection=crs)
  ax0.set_extent([lon3km_min, lon3km_max, lat3km_min, lat3km_max])
  ax0.add_geometries([ring], crs=crs, facecolor='blue', edgecolor='black')
  ax0.add_geometries([geom], crs=crs, alpha=0.3)
  
  plot_background(ax0)
  </code></pre>
  <p>This yields my outer domain, but not my inner domain:
  <a href="https://i.stack.imgur.com/7xXf9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7xXf9.png" alt="Outer domain, but no inner domain" /></a></p>
  <p>What am I doing wrong, and what can I do to get my inner domain shown on the map? Thank you for the help! I really appreciate it!</p>
  <p>NOTE: I have already attempted the solution in <a href="https://stackoverflow.com/questions/55303911/add-polygon-box-to-cartopy-python">this link.</a> I am still unable to visualize my polygon.</p>