Spaces:
Sleeping
Sleeping
File size: 1,966 Bytes
15bd62d e72f50c 985ceac a4a6bb0 bd83ae4 a4a6bb0 15bd62d 9ad0e2d 106ceac 9209524 9ad0e2d d2a7f71 9ad0e2d 9209524 9ad0e2d c975c5e 6bb3834 78eb7f4 17b5251 c975c5e 985ceac c975c5e 2f2ee27 f5137f9 e72f50c f5137f9 d2a7f71 2f2ee27 6302cb8 e72f50c 2f2ee27 48784bd 6524298 bec1f4e e72f50c 78eb7f4 bec1f4e 48784bd d2a7f71 d133030 6bb3834 2f2ee27 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
import streamlit as st
# import leafmap.foliumap as geemap
import geemap.foliumap as geemap
from streamlit.components.v1 import html
import ee
import folium
import pandas
# import geemap.foliumap as geemap
# import ee
from datetime import date, timedelta, datetime
st.set_page_config(layout="wide")
st.sidebar.info(
"""
URL: <https://onfarmview.com>
"""
)
st.sidebar.title("Contact")
st.sidebar.markdown('<a href="mailto:admin@onfarmview.com">Contact Us</a>', unsafe_allow_html=True)
st.title("On Farm View")
footer_content = """
<p>© 2023 On Farm View. </p>
"""
st.sidebar.markdown(footer_content, unsafe_allow_html=True)
def ee_authenticate(token_name="EARTHENGINE_TOKEN"):
geemap.ee_initialize(token_name=token_name)
def maskCloudAndShadows(image):
cloudProb = image.select('MSK_CLDPRB')
snowProb = image.select('MSK_SNWPRB')
cloud = cloudProb.lt(5)
snow = snowProb.lt(5)
scl = image.select('SCL')
shadow = scl.eq(3); # 3 = cloud shadow
cirrus = scl.eq(10); # 10 = cirrus
# Cloud probability less than 5% or cloud shadow classification
mask = (cloud.And(snow)).And(cirrus.neq(1)).And(shadow.neq(1))
return image.updateMask(mask).divide(10000)
map_center=(-43.525650, 172.639847)
ee_authenticate(token_name="EARTHENGINE_TOKEN")
m = geemap.Map(
basemap="HYBRID",
plugin_Draw=True,
Draw_export=True,
locate_control=True,
plugin_LatLngPopup=True,
center=map_center, zoom=15,
)
ed = date.today()
sd = ed - timedelta(days=30)
startDate = sd.strftime("%Y-%m-%d") + "T"
endDate = ed.strftime("%Y-%m-%d") + "T"
se2 = ee.ImageCollection('COPERNICUS/S2_SR').filterDate(
startDate,endDate).filter(
ee.Filter.lt("CLOUDY_PIXEL_PERCENTAGE",80)).map(maskCloudAndShadows).median()
band = ['B4','B3','B2']
rgbViza = {"min":0.0, "max":0.7,"bands":band}
titlemap = "Sentinel 2 - Natural Color"
m.addLayer(se2, rgbViza, titlemap)
m.to_streamlit(height=650)
|