Hi bjlittle,
The code that you provided worked for that example perfectly.
However when I tried to do the same thing for a different region it wouldn't create a square (please see attachment).
Here is the code:
import matplotlib.pyplot as plt
from matplotlib.transforms import offset_copy
import cartopy.crs as ccrs
import cartopy.io.img_tiles as cimgt
from shapely.geometry.polygon import LinearRing
def main():
map_quest_aerial=cimgt.MapQuestOpenAerial()
ax=plt.axes(projection=map_quest_aerial.crs)
ax.set_extent([-6,-8,57,59], ccrs.PlateCarree())
ax.add_image(map_quest_aerial, 8)
plt.plot(-7.017,58.311, marker='o', color='yellow', markersize=12, alpha=0.7, transform=ccrs.Geodetic())
geodetic_transform=ccrs.Geodetic()._as_mpl_transform(ax)
text_transform=offset_copy(geodetic_transform, units='dots', x=-25)
plt.text(-7.017, 58.311, u'Bernera Wave Site', verticalalignment='center', horizontalalignment='right', transform=text_transform, bbox=dict(facecolor='wheat', alpha=0.5, boxstyle='round'))
lons= [-7.3,-7.3,-7,-7]
lats=[58.4,58.61,58.4,58.61]
ring = LinearRing(list(zip(lons,lats)))
ax.add_geometries([ring], ccrs.PlateCarree(), facecolor='none', edgecolor='white')
plt.show()
if __name__ == '__main__':
main()
Do you know why this might be happening?
Thanks,
Jamie