import numpy as npimport xarray as xrimport matplotlib.pyplot as pltimport cartopy.crs as ccrsimport cartopy.feature as cfeaturefrom copy import copyfrom cartopy.mpl.gridliner import LATITUDE_FORMATTER, LONGITUDE_FORMATTERimport shapely.geometry as sgeomdef find_side(ls, side): """ Given a shapely LineString which is assumed to be rectangular, return the line corresponding to a given side of the rectangle. """ minx, miny, maxx, maxy = ls.bounds points = {'left': [(minx, miny), (minx, maxy)],