<jupyter_start><jupyter_text>Uncomment the following line to install [geemap](https://geemap.org) and [cartopy](https://scitools.org.uk/cartopy/docs/latest/installing.htmlinstalling) if needed. Keep in mind that cartopy can be challenging to install. If you are unable to install cartopy on your computer, you can try Google Colab with this the [notebook example](https://colab.research.google.com/github/giswqs/geemap/blob/master/examples/notebooks/cartoee_colab.ipynb). See below the commands to install cartopy and geemap using conda/mamba:```conda create -n gee python=3.9conda activate geeconda install mamba -c conda-forgemamba install cartopy scipy -c conda-forgemamba install geemap -c conda-forge```  Import libraries<jupyter_code>%pylab inline

import ee
import geemap

# import the cartoee functionality from geemap
from geemap import cartoee
import cartopy.io.img_tiles as cimgt<jupyter_output><empty_output><jupyter_text>Initialize Earth Engine<jupyter_code>geemap.ee_initialize()<jupyter_output><empty_output><jupyter_text>Add Earth Engine dataset<jupyter_code># get a landsat image to visualize
image = ee.Image('LANDSAT/LC08/C01/T1_SR/LC08_044034_20140318')

# define the visualization parameters to view
vis = {"bands": ['B5', 'B4', 'B3'], "min": 0, "max": 5000, "gamma": 1.3}<jupyter_output><empty_output><jupyter_text>Use Google basemap<jupyter_code>fig = plt.figure(figsize=(15, 10))

# use cartoee to get a map
ax = cartoee.get_map(image, vis_params=vis, basemap='ROADMAP', zoom_level=8)

# pad the view for some visual appeal
cartoee.pad_view(ax)

# add the gridlines and specify that the xtick labels be rotated 45 degrees
cartoee.add_gridlines(ax, interval=0.5, xtick_rotation=0, linestyle=":")

# add the coastline
ax.coastlines(color="yellow")

plt.show()<jupyter_output><empty_output><jupyter_text>Use Stamen Terrain basemap<jupyter_code>basemap = cimgt.Stamen('terrain-background')
fig = plt.figure(figsize=(15, 10))

# use cartoee to get a map
ax = cartoee.get_map(image, vis_params=vis, basemap=basemap, zoom_level=8)

# pad the view for some visual appeal
cartoee.pad_view(ax)

# add the gridlines and specify that the xtick labels be rotated 45 degrees
cartoee.add_gridlines(ax, interval=0.5, xtick_rotation=0, linestyle=":")

# add the coastline
ax.coastlines(color="yellow")

plt.show()<jupyter_output><empty_output><jupyter_text>Use OpenStreetMap basemap<jupyter_code>basemap = cimgt.OSM()
fig = plt.figure(figsize=(15, 10))

# use cartoee to get a map
ax = cartoee.get_map(image, vis_params=vis, basemap=basemap, zoom_level=8)

# pad the view for some visual appeal
cartoee.pad_view(ax)

# add the gridlines and specify that the xtick labels be rotated 45 degrees
cartoee.add_gridlines(ax, interval=0.5, xtick_rotation=0, linestyle=":")

# add the coastline
ax.coastlines(color="yellow")

plt.show()<jupyter_output><empty_output><jupyter_text>Use other basemapsFor more basemaps, see https://scitools.org.uk/cartopy/docs/v0.19/cartopy/io/img_tiles.html  Add text<jupyter_code>from matplotlib.transforms import offset_copy
import cartopy.crs as ccrs
fig = plt.figure(figsize=(15, 10))

# use cartoee to get a map
ax = cartoee.get_map(image, vis_params=vis, basemap='SATELLITE', zoom_level=8)

# pad the view for some visual appeal
cartoee.pad_view(ax)

# add the gridlines and specify that the xtick labels be rotated 45 degrees
cartoee.add_gridlines(ax, interval=0.5, xtick_rotation=0, linestyle=":")

# add the coastline
ax.coastlines(color="yellow")

plt.plot(-122.4457, 37.7574, marker='o', color='blue', markersize=10,
         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)

plt.text(-122.4457, 37.7574, u'San Francisco',
         verticalalignment='center', horizontalalignment='right',
         transform=text_transform, fontsize='large', fontweight='bold', color='white',
         bbox=dict(facecolor='sandybrown', alpha=0.5, boxstyle='round'))

# Save the plot by calling plt.savefig() BEFORE plt.show()
plt.savefig('sfo.pdf')
plt.savefig('sfo.jpg', dpi=300)

plt.show()<jupyter_output><empty_output><jupyter_text>![](https://i.imgur.com/Yw2N42R.png)  Global-scale maps<jupyter_code># 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, basemap=cimgt.Stamen('terrain'), zoom_level=2)
cb = cartoee.add_colorbar(ax, vis_params=visualization, loc='right', cmap='plasma')

ax.set_title(label='Sea Surface Temperature', fontsize=15)

ax.coastlines()

# Save the plot by calling plt.savefig() BEFORE plt.show()
plt.savefig('sst.pdf')
plt.savefig('sst.jpg', dpi=300)

plt.show()<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup