Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a legend to a cartoee map #343

Closed
giswqs opened this issue Mar 6, 2021 · 1 comment
Closed

Add a legend to a cartoee map #343

giswqs opened this issue Mar 6, 2021 · 1 comment
Labels
Feature Request New feature or request
Projects

Comments

@giswqs
Copy link
Member

giswqs commented Mar 6, 2021

Thanks to @GokulGeo for contributing the example.

# TCC Map
fig = plt.figure(figsize=(15,12))
# use cartoee to get a map
ax = cartoee.get_map(Sentinel_2_2,vis_params=vis_So_TCC ,region=zoom_region)

# add gridlines to the map at a specified interval
cartoee.add_gridlines(ax,interval=[0.015,0.015],linestyle=":")

ax.set_title(
    label = 'Breach 2: Sentinel-2(TCC), June 22,2020',
    fontsize = 15
)

cartoee.add_layer(ax, Embk_paint, region=zoom_region, vis_params=vis_emb)


cartoee.add_scale_bar(ax, 1, xy=(0.1, 0.02), linewidth=2, color="white", unit="km")
cartoee.add_north_arrow(ax, 'N', xy=(0.95, 0.9), arrow_length=0.1, text_color="white", arrow_color="white")

# add a marker for Breach
ax.plot(93.649587, 26.79789,'ko',color='#A8321D')
ax.text(93.649898, 26.79889,'Breach 2',color='#52FA71',fontweight='bold')


legend_elements = [Line2D([], [], color='#52FA71', lw=5, label='Embankment'),
    Line2D([], [], marker='o', color='#A8321D', label='Breach location',
                          markerfacecolor='#A8321D', markersize=10, ls ='')]
# Create the figure

ax.legend(handles=legend_elements, loc='lower right')

plt.show()

image

@giswqs giswqs added the Feature Request New feature or request label Mar 6, 2021
@giswqs giswqs added this to To do in geemap via automation Mar 6, 2021
giswqs added a commit that referenced this issue Mar 7, 2021
giswqs added a commit that referenced this issue Mar 11, 2021
@giswqs
Copy link
Member Author

giswqs commented Mar 11, 2021

This feature has been implemented. See notebook example https://geemap.org/notebooks/66_cartoee_legend

image

@giswqs giswqs closed this as completed Mar 11, 2021
geemap automation moved this from To do to Done Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request New feature or request
Projects
geemap
  
Done
Development

No branches or pull requests

1 participant