-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1.py
More file actions
140 lines (116 loc) · 3.61 KB
/
1.py
File metadata and controls
140 lines (116 loc) · 3.61 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import folium
import ee
import matplotlib.pyplot as plt
import seaborn as sns
import IPython.display as disp
from branca.element import Figure
import numpy as np
from dotenv import load_dotenv # added to load env variables
import os # added for env var support
load_dotenv(dotenv_path=".env.local") # load env variables from .env.local
PROJECT_ID = os.environ.get("PROJECT_ID") # get project id from env
ee.Authenticate()
ee.Initialize(project=PROJECT_ID) # modified to load project id from .env.local
from folium import Map, Marker
from folium.plugins import MarkerCluster
from branca.element import Figure
fig1 = Figure(width=550, height=350)
map1 = Map(location=[11.777968, 76.597909], zoom_start=12, width=550, height=350)
fig1.add_child(map1)
Marker(
location=[11.777968, 76.597909],
popup='Default popup Marker1',
tooltip='Click here to see Popup'
).add_to(map1)
fig1.save("map.html")
print("Map saved as map.html. Open it in your browser.")
watershed = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"coordinates": [
[
[
76.60413366762856,
11.78151054870402
],
[
76.57344831024034,
11.794260585249859
],
[
76.56196889596544,
11.78161860234809
],
[
76.55622918882744,
11.756549018691018
],
[
76.57377944719059,
11.750713529259215
],
[
76.60567897339666,
11.748119938711639
],
[
76.61450929206984,
11.769840505010293
],
[
76.63261144534937,
11.775243364615974
],
[
76.65866088543544,
11.787885640990154
],
[
76.65369383118195,
11.796853740543014
],
[
76.6294104548312,
11.810359361287453
],
[
76.60413366762856,
11.78151054870402
]
]
],
"type": "Polygon"
}
}
]
}
from folium import Map, Marker, GeoJson
from branca.element import Figure
# Your base map setup
fig1 = Figure(width=550, height=350)
map1 = Map(location=[11.777968, 76.597909], zoom_start=12, width=550, height=350)
fig1.add_child(map1)
# Add the GeoJSON layer (assuming 'watershed' is valid GeoJSON data)
GeoJson(
data=watershed,
style_function=lambda x: {'fillColor': 'orange'}
).add_to(map1)
# Save instead of display
fig1.save("map.html")
print("✅ Map with GeoJSON layer saved as 'map.html'. Open it in your browser.")
ee.Initialize(project=PROJECT_ID) # modified to load project id from .env.local
coords = watershed['features'][0]['geometry']['coordinates']
aoi = ee.Geometry.Polygon(coords)
image = ee.ImageCollection('COPERNICUS/S1_GRD').filterBounds(aoi).filterDate('2024-08-01', '2024-12-31').first().clip(aoi);
image.bandNames().getInfo()
url = image.select('VV').getThumbURL({'min': -20, 'max': 0})
disp.Image(url=url, width=800)
image.bandNames().getInfo()
url = image.select('VV').getThumbURL({'min': -20, 'max': 0})
disp.Image(url=url, width=800)
# image = ee.Image("COPERNICUS/S2/20220101T000239_20220101T000239_T56MNL")
# print(image.getInfo())