Spaces:
Sleeping
Sleeping
Commit
·
d2a7f71
1
Parent(s):
6bb3834
Commit my-awesome-file to the Hub
Browse files
app.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
# import leafmap.foliumap as geemap
|
| 3 |
import geemap.foliumap as geemap
|
| 4 |
-
|
| 5 |
from streamlit.components.v1 import html
|
| 6 |
import ee
|
| 7 |
import folium
|
|
@@ -22,7 +21,7 @@ st.sidebar.info(
|
|
| 22 |
|
| 23 |
st.sidebar.title("Contact")
|
| 24 |
|
| 25 |
-
st.sidebar.markdown('<a href="mailto:admin@onfarmview.com">Contact
|
| 26 |
|
| 27 |
st.title("On Farm View")
|
| 28 |
|
|
@@ -38,6 +37,17 @@ st.sidebar.markdown(footer_content, unsafe_allow_html=True)
|
|
| 38 |
def ee_authenticate(token_name="EARTHENGINE_TOKEN"):
|
| 39 |
geemap.ee_initialize(token_name=token_name)
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
map_center=(-43.525650, 172.639847)
|
| 43 |
ee_authenticate(token_name="EARTHENGINE_TOKEN")
|
|
@@ -51,6 +61,21 @@ m = geemap.Map(
|
|
| 51 |
center=map_center, zoom=15,
|
| 52 |
)
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
m.to_streamlit(height=650)
|
| 56 |
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
# import leafmap.foliumap as geemap
|
| 3 |
import geemap.foliumap as geemap
|
|
|
|
| 4 |
from streamlit.components.v1 import html
|
| 5 |
import ee
|
| 6 |
import folium
|
|
|
|
| 21 |
|
| 22 |
st.sidebar.title("Contact")
|
| 23 |
|
| 24 |
+
st.sidebar.markdown('<a href="mailto:admin@onfarmview.com">Contact Us</a>', unsafe_allow_html=True)
|
| 25 |
|
| 26 |
st.title("On Farm View")
|
| 27 |
|
|
|
|
| 37 |
def ee_authenticate(token_name="EARTHENGINE_TOKEN"):
|
| 38 |
geemap.ee_initialize(token_name=token_name)
|
| 39 |
|
| 40 |
+
def maskCloudAndShadows(image):
|
| 41 |
+
cloudProb = image.select('MSK_CLDPRB')
|
| 42 |
+
snowProb = image.select('MSK_SNWPRB')
|
| 43 |
+
cloud = cloudProb.lt(5)
|
| 44 |
+
snow = snowProb.lt(5)
|
| 45 |
+
scl = image.select('SCL')
|
| 46 |
+
shadow = scl.eq(3); # 3 = cloud shadow
|
| 47 |
+
cirrus = scl.eq(10); # 10 = cirrus
|
| 48 |
+
# Cloud probability less than 5% or cloud shadow classification
|
| 49 |
+
mask = (cloud.And(snow)).And(cirrus.neq(1)).And(shadow.neq(1))
|
| 50 |
+
return image.updateMask(mask).divide(10000)
|
| 51 |
|
| 52 |
map_center=(-43.525650, 172.639847)
|
| 53 |
ee_authenticate(token_name="EARTHENGINE_TOKEN")
|
|
|
|
| 61 |
center=map_center, zoom=15,
|
| 62 |
)
|
| 63 |
|
| 64 |
+
ed = date.today()
|
| 65 |
+
sd = ed - timedelta(days=30)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
startDate = sd.strftime("%Y-%m-%d") + "T"
|
| 69 |
+
endDate = ed.strftime("%Y-%m-%d") + "T"
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
se2 = ee.ImageCollection('COPERNICUS/S2_SR').filterDate(
|
| 73 |
+
startDate,endDate).filter(
|
| 74 |
+
ee.Filter.lt("CLOUDY_PIXEL_PERCENTAGE",80)).map(maskCloudAndShadows).median()
|
| 75 |
+
band = ['B4','B3','B2']
|
| 76 |
+
rgbViza = {"min":0.0, "max":0.7,"bands":band}
|
| 77 |
+
titlemap = "Sentinel 2 - Natural Color"
|
| 78 |
+
m.addLayer(se2, rgbViza, titlemap)
|
| 79 |
|
| 80 |
m.to_streamlit(height=650)
|
| 81 |
|