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 scale bar and a north arrow #191

Closed
ErikSeras opened this issue Dec 4, 2020 · 3 comments
Closed

Add a scale bar and a north arrow #191

ErikSeras opened this issue Dec 4, 2020 · 3 comments
Assignees
Labels
Feature Request New feature or request question Further information is requested

Comments

@ErikSeras
Copy link
Contributor

  • geemap version: 0.8.3
  • Python version: 3.6.9
  • Operating System: Google Colab

Description

I used COPERNICUS/S2_SR to be able to represent the Lewato volcano eruption, Indonesia.

lewato_volcano

How can I add a scale bar and a north arrow?

What I Did

import ee
import geemap.eefolium as geemap
from geemap import cartoee as cee

%pylab inline

try:
    ee.Initialize()
except Exception as e:
    ee.Authenticate()
    ee.Initialize()

point = ee.Geometry.Point(123.488, -8.284)

volcano = ee.ImageCollection("COPERNICUS/S2_SR").filterBounds(point).filterDate("2020-11-28", "2020-12-04").first()

plt.figure(figsize=(16, 12))

region = [123.3,-8.5,123.8,-8.18]
vis = {'min':0,'max':6000, 'bands':'B4,B3,B2'}

ax = cee.get_map(volcano, region=region, vis_params=vis)
cee.add_gridlines(ax,interval=(0.1,0.1),linestyle=":")

ax.set_title(
    label = 'Lewato volcano 2020-11-29',
    fontsize = 15
)

plt.show()

Thanks for your help!

@KMarkert KMarkert added the question Further information is requested label Dec 4, 2020
@KMarkert
Copy link
Member

KMarkert commented Dec 4, 2020

To add a scale bar and north arrow one would need to do draw on the figure yourself using matplotlib/cartopy graphics elements. Unfortunately, there really no easy solution available for this right now, although it looks like others have shared code to get started. Here is a thread on stackoverflow regarding this same problem: https://stackoverflow.com/questions/32333870/how-can-i-show-a-km-ruler-on-a-cartopy-matplotlib-plot and another issue thread on the cartopy repo: SciTools/cartopy#490.

I don't think we would want to consider this a feature request for this package given this is more low-level functionality and would be best if implemented in cartopy. I hope this helps.

P.S. That is a pretty amazing image that S2 captured!

@ErikSeras
Copy link
Contributor Author

Thank you very much for your help @KMarkert.

@KMarkert KMarkert closed this as completed Dec 4, 2020
@giswqs giswqs reopened this Dec 13, 2020
@giswqs giswqs added the Feature Request New feature or request label Dec 13, 2020
@giswqs giswqs self-assigned this Dec 13, 2020
@giswqs
Copy link
Member

giswqs commented Dec 13, 2020

Thanks to the stackoverflow sample code. I have added two more functions to cartoee, add_scale_bar() and add_north_arrow(). See notebook example - cartoee_scalebar.ipynb

@KMarkert @jdbcode @ErikSeras @GokulGeo

@giswqs giswqs closed this as completed Dec 13, 2020
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 question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants