# !pip install cartopy scipy # !pip install geemap import ee import geemap from geemap import cartoee import cartopy.crs as ccrs %pylab inline geemap.ee_initialize() # get an earth engine image of ocean data for Jan-Mar 2018 ocean = ( ee.ImageCollection('NASA/OCEANDATA/MODIS-Terra/L3SMI') .filter(ee.Filter.date('2018-01-01', '2018-03-01')) .median() .select(["sst"], ["SST"]) ) # set parameters for plotting # will plot the Sea Surface Temp with specific range and colormap visualization = {'bands': "SST", 'min': -2, 'max': 30} # specify region to focus on bbox = [180, -88, -180, 88] fig = plt.figure(figsize=(15, 10)) # plot the result with cartoee using a PlateCarre projection (default) ax = cartoee.get_map(ocean, cmap='plasma', vis_params=visualization, region=bbox) cb = cartoee.add_colorbar(ax, vis_params=visualization, loc='right', cmap='plasma') ax.set_title(label='Sea Surface Temperature', fontsize=15) ax.coastlines() plt.show() fig = plt.figure(figsize=(15, 10)) # create a new Mollweide projection centered on the Pacific projection = ccrs.Mollweide(central_longitude=-180) # plot the result with cartoee using the Mollweide projection ax = cartoee.get_map( ocean, vis_params=visualization, region=bbox, cmap='plasma', proj=projection ) cb = cartoee.add_colorbar( ax, vis_params=visualization, loc='bottom', cmap='plasma', orientation='horizontal' ) ax.set_title("Mollweide projection") ax.coastlines() plt.show() fig = plt.figure(figsize=(15, 10)) # create a new Goode homolosine projection centered on the Pacific projection = ccrs.Robinson(central_longitude=-180) # plot the result with cartoee using the Goode homolosine projection ax = cartoee.get_map( ocean, vis_params=visualization, region=bbox, cmap='plasma', proj=projection ) cb = cartoee.add_colorbar( ax, vis_params=visualization, loc='bottom', cmap='plasma', orientation='horizontal' ) ax.set_title("Robinson projection") ax.coastlines() plt.show() fig = plt.figure(figsize=(15, 10)) # create a new Goode homolosine projection centered on the Pacific projection = ccrs.InterruptedGoodeHomolosine(central_longitude=-180) # plot the result with cartoee using the Goode homolosine projection ax = cartoee.get_map( ocean, vis_params=visualization, region=bbox, cmap='plasma', proj=projection ) cb = cartoee.add_colorbar( ax, vis_params=visualization, loc='bottom', cmap='plasma', orientation='horizontal' ) ax.set_title("Goode homolosine projection") ax.coastlines() plt.show() fig = plt.figure(figsize=(15, 10)) # create a new orographic projection focused on the Pacific projection = ccrs.EqualEarth(central_longitude=-180) # plot the result with cartoee using the orographic projection ax = cartoee.get_map( ocean, vis_params=visualization, region=bbox, cmap='plasma', proj=projection ) cb = cartoee.add_colorbar( ax, vis_params=visualization, loc='right', cmap='plasma', orientation='vertical' ) ax.set_title("Equal Earth projection") ax.coastlines() plt.show() fig = plt.figure(figsize=(15, 10)) # create a new orographic projection focused on the Pacific projection = ccrs.Orthographic(-130, -10) # plot the result with cartoee using the orographic projection ax = cartoee.get_map( ocean, vis_params=visualization, region=bbox, cmap='plasma', proj=projection ) cb = cartoee.add_colorbar( ax, vis_params=visualization, loc='right', cmap='plasma', orientation='vertical' ) ax.set_title("Orographic projection") ax.coastlines() plt.show() fig = plt.figure(figsize=(15, 10)) # Create a new region to focus on spole = [180, -88, -180, 0] projection = ccrs.SouthPolarStereo() # plot the result with cartoee focusing on the south pole ax = cartoee.get_map( ocean, cmap='plasma', vis_params=visualization, region=spole, proj=projection ) cb = cartoee.add_colorbar(ax, vis_params=visualization, loc='right', cmap='plasma') ax.coastlines() ax.set_title('The South Pole') plt.show() fig = plt.figure(figsize=(15, 10)) # plot the result with cartoee focusing on the south pole ax = cartoee.get_map( ocean, cmap='plasma', vis_params=visualization, region=spole, proj=projection ) cb = cartoee.add_colorbar(ax, vis_params=visualization, loc='right', cmap='plasma') ax.coastlines() ax.set_title('The South Pole') # get bounding box coordinates of a zoom area zoom = spole zoom[-1] = -20 # convert bbox coordinate from [W,S,E,N] to [W,E,S,N] as matplotlib expects zoom_extent = cartoee.bbox_to_extent(zoom) # set the extent of the map to the zoom area ax.set_extent(zoom_extent, ccrs.PlateCarree()) plt.show()