<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 carto python=3.8conda activate cartoconda install mamba -c conda-forgemamba install cartopy scipy -c conda-forgemamba install geemap -c conda-forgejupyter notebook```<jupyter_code># !pip install cartopy scipy
# !pip install geemap
%pylab inline

import ee
import geemap

# import the cartoee functionality from geemap
from geemap import cartoee
geemap.ee_initialize()<jupyter_output><empty_output><jupyter_text>Plot an RGB image<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}
fig = plt.figure(figsize=(15, 10))

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

# 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="cyan")

show()<jupyter_output><empty_output><jupyter_text>By default, if a region is not provided via the `region` keyword the whole extent of the image will be plotted as seen in the previous Landsat example. We can also zoom to a specific region of an image by defining the region to plot.<jupyter_code>fig = plt.figure(figsize=(15, 10))

# here is the bounding box of the map extent we want to use
# formatted a [E,S,W,N]
zoom_region = [-121.8025, 37.3458, -122.6265, 37.9178]

# plot the map over the region of interest
ax = cartoee.get_map(image, vis_params=vis, region=zoom_region)

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

# add coastline
ax.coastlines(color="cyan")

show()<jupyter_output><empty_output><jupyter_text>Adding north arrow, scale bar, and legend<jupyter_code>fig = plt.figure(figsize=(15, 10))

# here is the bounding box of the map extent we want to use
# formatted a [E,S,W,N]
zoom_region = [-121.8025, 37.3458, -122.6265, 37.9178]

# plot the map over the region of interest
ax = cartoee.get_map(image, vis_params=vis, region=zoom_region)

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

# add coastline
ax.coastlines(color="cyan")

# add north arrow
cartoee.add_north_arrow(ax, text="N", xy=(0.05, 0.25), text_color="white", arrow_color="white", fontsize=20)

# add scale bar
cartoee.add_scale_bar_lite(ax, length=10, xy=(0.1, 0.05), fontsize=20, color="white", unit="km")

ax.set_title(label = 'Landsat False Color Composite (Band 5/4/3)', fontsize=15)

# add legend
legend_elements = [Line2D([], [], color='#00ffff', lw=2, label='Coastline'),
    Line2D([], [], marker='o', color='#A8321D', label='City', markerfacecolor='#A8321D', markersize=10, ls ='')]

cartoee.add_legend(ax, legend_elements, loc='lower right')

show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12188288035864388, 'fraction_numerical': 0.04230876996357523, 'mean_word_length': 5.932038834951456, 'pattern_counts': {'":': 7, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '145765', 'license': 'MIT', 'n_tokens_mistral': 1370, 'n_tokens_neox': 1262, 'n_words': 369, 'path': 'examples/notebooks/66_cartoee_legend.ipynb', 'repo_name': 'Yisheng-Li/geemap', 'size': '3569'}