geetools, and it is still under active development on https://github.com/gee-community/gee_tools. There are 2 options:Map.show() to show the map. Can't add more layers afterwards.maptool
In [ ]:
import ee
ee.Initialize()
In [ ]:
col = ee.ImageCollection('COPERNICUS/S2')
site = ee.Geometry.Point([-72, -42])
col = col.filterBounds(site).filterMetadata('CLOUD_COVERAGE_ASSESSMENT', 'less_than', 40)
i = ee.Image(col.first())
igeom = i.geometry()
In [ ]:
visParam = {'bands':['B8', 'B11', 'B4'], 'min':0, 'max':5000}
addLayer has a parameter called inspect that defines de content for a pop up, which is a dict with the following keys:
In [ ]:
inspect = {'data':i, 'reducer':'mean'}
In [ ]:
from geetools.ui import maptool
Map = maptool.Map()
Map.addLayer(i, visParam, 'Sentinel 2 Patagonia')
Map.centerObject(i)
Map.addLayer(igeom, name='Image boundries', inspect=inspect)
Map.show()
In [ ]:
from geetools import ui
Map2 = ui.Map()
# you can do also:
# from geetools.ui import ipymap
# Map2 = ipymap.Map()
In [ ]:
Map2.show()
In [ ]:
Map2.addLayer(i, visParam, 'Sentinel 2 Patagonia')
In [ ]:
Map2.addLayer(i, {'bands':['B8'], 'min':0, 'max':5000}, 'just B8')
In [ ]:
Map2.centerObject(i)
In [ ]:
Map2.addLayer(igeom, name='Image boundries')
In [ ]:
Map2.centerObject(igeom)
In [ ]:
center = Map2.getCenter()
center.getInfo()
In [ ]:
bounds = Map2.getBounds()
bounds.getInfo()
In [ ]:
Map2.removeLayer('Sentinel 2 Patagonia')
In [ ]:
print(Map2.addTab.__doc__)
In [ ]:
def test_handler(**change):
# PARAMS
ty = change['type']
coords = change['coordinates']
wid = change['widget']
themap = change['map']
if ty == 'click': # If interaction was a click
# Loading message before sending a request to EE
wid.value = 'Loading...'
# Map's bounds
bounds = themap.getBounds().getInfo()['coordinates']
# Change Widget Value
wid.value = "You have clicked on {} and map's bounds are {}".format(coords, bounds)
Map2.addTab('TestTAB', test_handler)
print("Check out the Map!")
In [ ]: