import cartopy.crs as ccrs import matplotlib.pyplot as plt %matplotlib inline ax = plt.axes(projection=ccrs.epsg(28992)) ax.stock_img() plt.show() import cartopy.crs as ccrs import matplotlib.pyplot as plt %matplotlib inline ax = plt.axes(projection=ccrs.PlateCarree()) ax.stock_img() ny_lon, ny_lat = -75, 43 delhi_lon, delhi_lat = 77.23, 28.61 plt.plot([ny_lon, delhi_lon], [ny_lat, delhi_lat], color='blue', linewidth=2, marker='o', transform=ccrs.Geodetic(), ) plt.plot([ny_lon, delhi_lon], [ny_lat, delhi_lat], color='gray', linestyle='--', transform=ccrs.PlateCarree(), ) plt.text(ny_lon - 3, ny_lat - 12, 'New York', horizontalalignment='right', transform=ccrs.Geodetic()) plt.text(delhi_lon + 3, delhi_lat - 12, 'Delhi', horizontalalignment='left', transform=ccrs.Geodetic()) plt.show() import matplotlib.pyplot as plt from matplotlib.transforms import offset_copy %matplotlib inline import cartopy.crs as ccrs import cartopy.io.img_tiles as cimgt # Create a MapQuest open aerial instance. map_quest_aerial = cimgt.MapQuestOpenAerial() # Create a GeoAxes in the tile's projection. ax = plt.axes(projection=map_quest_aerial.crs) # Limit the extent of the map to a small longitude/latitude range. ax.set_extent([-22, -15, 63, 65]) # Add the MapQuest data at zoom level 8. ax.add_image(map_quest_aerial, 8) # Add a marker for the Eyjafjallajökull volcano. plt.plot(-19.613333, 63.62, marker='o', color='yellow', markersize=12, alpha=0.7, transform=ccrs.Geodetic()) # Use the cartopy interface to create a matplotlib transform object # for the Geodetic coordinate system. We will use this along with # matplotlib's offset_copy function to define a coordinate system which # translates the text by 25 pixels to the left. geodetic_transform = ccrs.Geodetic()._as_mpl_transform(ax) text_transform = offset_copy(geodetic_transform, units='dots', x=-25) # Add text 25 pixels to the left of the volcano. plt.text(-19.613333, 63.62, u'Eyjafjallajökull', verticalalignment='center', horizontalalignment='right', transform=text_transform, bbox=dict(facecolor='wheat', alpha=0.5, boxstyle='round')) plt.show() import cartopy.crs as ccrs import matplotlib.pyplot as plt %matplotlib inline url = 'http://map1c.vis.earthdata.nasa.gov/wmts-geo/wmts.cgi' layer = 'VIIRS_CityLights_2012' ax = plt.axes(projection=ccrs.PlateCarree()) ax.add_wmts(url, layer) ax.set_extent((-15, 25, 35, 60)) plt.title('Suomi NPP Earth at night April/October 2012') plt.show() from matplotlib.path import Path import matplotlib.pyplot as plt %matplotlib inline import numpy as np import cartopy.crs as ccrs from cartopy.io.img_tiles import MapQuestOSM def tube_locations(): """ Returns an (n, 2) array of selected London Tube locations in Ordnance Survey GB coordinates. Source: http://www.doogal.co.uk/london_stations.php """ return np.array([[531738., 180890.], [532379., 179734.], [531096., 181642.], [530234., 180492.], [531688., 181150.], [530242., 180982.], [531940., 179144.], [530406., 180380.], [529012., 180283.], [530553., 181488.], [531165., 179489.], [529987., 180812.], [532347., 180962.], [529102., 181227.], [529612., 180625.], [531566., 180025.], [529629., 179503.], [532105., 181261.], [530995., 180810.], [529774., 181354.], [528941., 179131.], [531050., 179933.], [530240., 179718.]]) imagery = MapQuestOSM() ax = plt.axes(projection=imagery.crs) ax.set_extent((-0.14, -0.1, 51.495, 51.515)) # Construct concentric circles and a rectangle, # suitable for a London Underground logo. theta = np.linspace(0, 2 * np.pi, 100) circle_verts = np.vstack([np.sin(theta), np.cos(theta)]).T concentric_circle = Path.make_compound_path(Path(circle_verts[::-1]), Path(circle_verts * 0.6)) rectangle = Path([[-1.1, -0.2], [1, -0.2], [1, 0.3], [-1.1, 0.3]]) # Add the imagery to the map. ax.add_image(imagery, 14) # Plot the locations twice, first with the red concentric circles, # then with the blue rectangle. xs, ys = tube_locations().T plt.plot(xs, ys, transform=ccrs.OSGB(), marker=concentric_circle, color='red', markersize=9, linestyle='') plt.plot(xs, ys, transform=ccrs.OSGB(), marker=rectangle, color='blue', markersize=11, linestyle='') plt.title('London underground locations') plt.show()