import ee

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

# %%
"""
## Create an interactive map 
The default basemap is `Google Satellite`. [Additional basemaps](https://github.com/giswqs/geemap/blob/master/geemap/geemap.py#L13) can be added using the `Map.add_basemap()` function. 
"""

# %%
Map = emap.Map(center=[40, -100], zoom=4)
Map.add_basemap('ROADMAP')  # Add Google Map
Map

# %%
"""
## Add Earth Engine Python script 
"""

# %%
# Add Earth Engine dataset
dataset = ee.Image('CSP/ERGo/1_0/US/topoDiversity')
usTopographicDiversity = dataset.select('constant')
usTopographicDiversityVis = {
    'min': 0.0,
    'max': 1.0,
# ## Filter NAIP image collection by time and aoi

# In[3]:

long_lat = ee.Geometry.Point(long, lat)
naip = collection.filterBounds(aoi)
naip17 = collection.filterDate('2017-05-01', '2017-8-05')
count = naip17.size().getInfo()
print('Count:', count)

# ## Display NAIP images for aoi

# In[4]:

Map = emap.Map(center=[lat, long], zoom=15)

Map.add_basemap('TERRAIN')
#vis = {'bands': ['N', 'R', 'G']}

vis = {'bands': ['R', 'G', 'B']}
imgs = naip17.mosaic().clip(aoi)
#Map.addLayer(aoi)
Map.addLayer(imgs, vis)
Map

# ## Calculate NDVI

# In[5]:

#nir, r = imgs.select('N'), imgs.select('R')
Esempio n. 3
0
centroid = aoi.centroid()
long, lat = centroid.getInfo()['coordinates']
print("long = {}, lat = {}".format(long, lat))

# In[5]:

long_lat = ee.Geometry.Point(long, lat)
naip = collection.filterBounds(aoi)
naip15 = collection.filterDate('2015-05-01', '2015-10-30')
imgs = naip15.mosaic().clip(aoi)
count = naip15.size().getInfo()
print('Count:', count)

# In[6]:

Map = emap.Map(center=[lat, long], zoom=14)

Map.add_basemap('SATELLITE')
#vis = {'bands': ['N', 'R', 'G']}

vis = {'bands': ['R', 'G', 'B']}
imgs = naip15.mosaic().clip(aoi)
#Map.addLayer(aoi)
Map.addLayer(imgs, vis)
Map

# In[7]:

#nir, r = imgs.select('N'), imgs.select('R')
ndvi = imgs.normalizedDifference(["N", "R"])
ndvi_vis = {'min': -1, 'max': 1, 'palette': ['red', 'yellow', 'green']}
Esempio n. 4
0
import streamlit as st
import ee
import geemap.eefolium as geemap
from streamlit_folium import folium_static

Map = geemap.Map()
# Map
# Add Earth Engine dataset
image = ee.ImageCollection('TUBerlin/BigEarthNet/v1')

# Set visualization parameters.
vis_params = {'min': 0, 'max': 4000}

# Print the elevation of Mount Everest.
lon = 13.18
lat = 52.52

lon = float(st.sidebar.text_input('longitude', 13.34))
lat = float(st.sidebar.text_input('latitude', 52.53))
xy = ee.Geometry.Point([lon, lat])
#elev = image.sample(xy, 30).first().get('elevation').getInfo()
#print('Mount Everest elevation (m):', elev)

# Add Earth Engine layers to Map
Map.addLayer(image, vis_params)
Map.addLayer(xy, {'color': 'red'}, 'random point(data)')

# Center the map based on an Earth Engine object or coordinates (longitude, latitude)
Map.centerObject(xy, 8)

Map.addLayerControl()