Skip to content

Commit 0cc991f

Browse files
Updated GAIA.ipynb to 0.41b
1 parent 153adca commit 0cc991f

File tree

1 file changed

+77
-43
lines changed

1 file changed

+77
-43
lines changed

GAIA.ipynb

Lines changed: 77 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@
1616
"import logging\n",
1717
"import geocoder\n",
1818
"import folium\n",
19+
"import json\n",
20+
"import matplotlib.pyplot as plt\n",
1921
"from folium.plugins import Draw\n",
2022
"from ipyleaflet import *\n",
2123
"from colorama import Fore\n",
24+
"from PIL import Image\n",
2225
"\n",
2326
"# PROGRAM MODULES IMPORT\n",
2427
"sys.path.insert(0, 'gee//modules//') # gee modules path\n",
@@ -53,7 +56,7 @@
5356
"\n",
5457
"mr.Markdown(text = '**🌎 GAIA - Geospatial & Aerial Images Analyser [BETA] 🌎**')\n",
5558
"mr.Markdown(text = '**🌎 This program solution is not final and some details are potentially to be changed 🌎**')\n",
56-
"mr.Markdown(text = '**🌏 Current version - 0.4b 🌏**')\n",
59+
"mr.Markdown(text = '**🌏 Current version - 0.41b 🌏**')\n",
5760
"\n",
5861
"text = 'OSINT-TECHNOLOGIES'\n",
5962
"text_params = {\n",
@@ -68,9 +71,9 @@
6871
"}\n",
6972
"\n",
7073
"sources_list = [\"Google EE\", \"OpenStreetMap\"]\n",
71-
"control_panel_choice = mr.Select(value=\"Google EE\", choices=sources_list, label=\"Choose the source control panel\")\n",
74+
"control_panel_choice = mr.Select(value=\"Google EE\", choices=sources_list, label=\"Choose the source control panel 🔍\")\n",
7275
"\n",
73-
"app = mr.App(title=\"GAIA v0.4b [BETA] 🌐\",\n",
76+
"app = mr.App(title=\"GAIA v0.41b [BETA] 🌐\",\n",
7477
" description=\"Open-Source Geospatial & Aerial Images Analyser\",\n",
7578
" show_code=False,\n",
7679
" show_prompt=False,\n",
@@ -92,26 +95,6 @@
9295
"# GOOGLE EE PROCESSING\n",
9396
"\n",
9497
"if control_panel_choice.value == \"Google EE\":\n",
95-
" ee_user_guide = mr.Button(label=\"How to start Google EE\")\n",
96-
" ee_reg = mr.Button(label=\"EE registration\")\n",
97-
" ee_service_acc = mr.Button(label=\"Create EE service account\")\n",
98-
" save_map_html = mr.Button(label=\"Save current map [HTML]\")\n",
99-
" ds_info = mr.Checkbox(value=False, label='Show datasets technical info')\n",
100-
" manual_input = mr.Checkbox(value=False, label='Open custom GEE dataset menu')\n",
101-
" date_one = mr.Text(value=\"2022-01-01\", label=\"Enter start date (format YYYY-MM-DD)\", rows=1)\n",
102-
" date_two = mr.Text(value=\"2022-01-02\", label=\"Enter final date (format YYYY-MM-DD)\", rows=1)\n",
103-
" max_cloud_covering = mr.Slider(value=80, label='Max cloud cover (%, may affect datasets quality)', min=0, max=100)\n",
104-
" datasets_landsat = mr.Checkbox(value=False, label=\"Show Landsat datasets\")\n",
105-
" datasets_sentinel = mr.Checkbox(value=False, label=\"Show Sentinel datasets\")\n",
106-
" datasets_modis = mr.Checkbox(value=False, label=\"Show MODIS datasets\")\n",
107-
" datasets_other = mr.Checkbox(value=False, label='Show other datasets')\n",
108-
"\n",
109-
" if ee_reg.clicked:\n",
110-
" webbrowser.open_new_tab('https://code.earthengine.google.com/register')\n",
111-
" \n",
112-
" if ee_service_acc.clicked:\n",
113-
" webbrowser.open_new_tab('https://console.cloud.google.com/iam-admin/serviceaccounts/')\n",
114-
" \n",
11598
" if str((cec.service_acc_filename).rstrip()) not in os.listdir():\n",
11699
" print(Fore.RED + '[File/directory missing error]. Your EE credentials .JSON file was not found in GAIA directory')\n",
117100
" mr.Stop()\n",
@@ -120,47 +103,87 @@
120103
" service_account = (cec.service_acc_mail).rstrip()\n",
121104
" credentials = ee.ServiceAccountCredentials(service_account, key_file)\n",
122105
" ee.Initialize(credentials)\n",
123-
"\n",
106+
" \n",
124107
" m = geemap.Map()\n",
125-
" m.add_text(text, **text_params)\n",
126108
" m.add_basemap('SATELLITE')\n",
127109
" m.add_basemap('TERRAIN')\n",
128110
" m.add_basemap('HYBRID')\n",
129-
" \n",
111+
"\n",
112+
" ee_user_guide = mr.Checkbox(value=False, label=\"How to start Google EE\")\n",
113+
" ds_info = mr.Checkbox(value=False, label='Show datasets knowledge base')\n",
114+
"\n",
115+
" date_one = mr.Text(value=\"2022-01-01\", label=\"Enter start date (format YYYY-MM-DD)\", rows=1)\n",
116+
" date_two = mr.Text(value=\"2022-01-02\", label=\"Enter final date (format YYYY-MM-DD)\", rows=1)\n",
117+
"\n",
118+
" max_cloud_covering = mr.Slider(value=80, label='Max cloud cover (%, may affect datasets quality)', min=0, max=100)\n",
119+
" datasets_landsat = mr.Checkbox(value=False, label=\"Show Landsat datasets\")\n",
120+
" datasets_sentinel = mr.Checkbox(value=False, label=\"Show Sentinel datasets\")\n",
121+
" datasets_modis = mr.Checkbox(value=False, label=\"Show MODIS datasets\")\n",
122+
" datasets_other = mr.Checkbox(value=False, label='Show other datasets')\n",
123+
" \n",
130124
" try:\n",
131-
" if manual_input.value:\n",
132-
" custom_ds = mr.Text(value=\"-\", label=\"[Custom DS] Enter GEE dataset name\", rows=1)\n",
133-
" date_one_custom = mr.Text(value=\"1972-01-01\", label=\"[Custom DS] Enter start date (format YYYY-MM-DD)\", rows=1)\n",
134-
" date_two_custom = mr.Text(value=\"1973-01-01\", label=\"[Custom DS] Enter final date (format YYYY-MM-DD)\", rows=1)\n",
135-
" cd_init.customds_initialization(m, date_one_custom, date_two_custom, custom_ds)\n",
136-
" \n",
137125
" if datasets_landsat.value:\n",
138126
" l_init.landsat_initialization(m, date_one, date_two, max_cloud_covering)\n",
139127
" \n",
140128
" if datasets_sentinel.value:\n",
141129
" s_init.sentinel_initialization(m, date_one, date_two, max_cloud_covering)\n",
142-
" \n",
130+
" \n",
143131
" if datasets_modis.value:\n",
144132
" m_init.modis_initialization(m, date_one, date_two)\n",
145-
" \n",
133+
" \n",
146134
" if datasets_other.value:\n",
147-
" o_init.others_initialization(m, date_one, date_two)\n",
148-
" \n",
135+
" o_init.others_initialization(m, date_one, date_two) \n",
149136
" except ee.EEException as error:\n",
150137
" print(Fore.RED + '[Map plotting/initialization error] - {}'.format(str(error)))\n",
151138
" logger.error(error)\n",
152139
" pass\n",
140+
"\n",
141+
" manual_input = mr.Checkbox(value=False, label='Open custom GEE dataset menu')\n",
142+
" if manual_input.value:\n",
143+
" try:\n",
144+
" custom_ds = mr.Text(value=\"-\", label=\"[Custom DS] Enter GEE dataset name\", rows=1)\n",
145+
" date_one_custom = mr.Text(value=\"1972-01-01\", label=\"[Custom DS] Enter start date (format YYYY-MM-DD)\", rows=1)\n",
146+
" date_two_custom = mr.Text(value=\"1973-01-01\", label=\"[Custom DS] Enter final date (format YYYY-MM-DD)\", rows=1)\n",
147+
" cd_init.customds_initialization(m, date_one_custom, date_two_custom, custom_ds)\n",
148+
" except ee.EEException as error:\n",
149+
" print(Fore.RED + '[Map plotting/initialization error] - {}'.format(str(error)))\n",
150+
" logger.error(error)\n",
151+
" pass\n",
152+
"\n",
153+
" save_map_html = mr.Button(label=\"Save current map [HTML]\")\n",
154+
" ee_reg = mr.Button(label=\"EE registration\")\n",
155+
" ee_service_acc = mr.Button(label=\"Create EE service account\")\n",
156+
"\n",
157+
" if ee_reg.clicked:\n",
158+
" webbrowser.open_new_tab('https://code.earthengine.google.com/register')\n",
153159
" \n",
160+
" if ee_service_acc.clicked:\n",
161+
" webbrowser.open_new_tab('https://console.cloud.google.com/iam-admin/serviceaccounts/')\n",
162+
"\n",
163+
" m.add_text(text, **text_params)\n",
164+
" \n",
154165
" mr.Markdown(text = \"#GOOGLE EARTH ENGINE MAP 🌐\")\n",
155166
" mr.Markdown(text = \"**DATASETS TIME PERIOD: from {} to {}**\".format(date_one.value, date_two.value))\n",
156167
" \n",
157168
" if manual_input.value:\n",
158169
" mr.Markdown(text = \"**CUSTOM DATASETS TIME PERIOD: from {} to {}**\".format(date_one_custom.value, date_two_custom.value))\n",
159170
" \n",
160171
" if ds_info.value:\n",
172+
" mr.Markdown(text=\"**LANDSAT BANDS COMBINATIONS ⤵**\")\n",
173+
" clb = Image.open('gee//data//clb.png')\n",
174+
" plt.figure(figsize=(7, 7))\n",
175+
" plt.imshow(clb)\n",
176+
" plt.axis('off')\n",
177+
" plt.show()\n",
178+
" mr.Markdown(text=\"**SENTINEL 2 BANDS COMBINATIONS ⤵**\")\n",
179+
" csb = Image.open('gee//data//csb.png')\n",
180+
" plt.figure(figsize=(7, 7))\n",
181+
" plt.imshow(csb)\n",
182+
" plt.axis('off')\n",
183+
" plt.show()\n",
161184
" txtr.ds_info_read()\n",
162-
" \n",
163-
" if ee_user_guide.clicked:\n",
185+
"\n",
186+
" if ee_user_guide.value:\n",
164187
" txtr.ee_guide_read()\n",
165188
" \n",
166189
" download_dir = os.path.join(os.path.expanduser('~'), 'Downloads')\n",
@@ -185,16 +208,29 @@
185208
"\n",
186209
"if control_panel_choice.value == \"OpenStreetMap\":\n",
187210
" mr.Markdown(text = \"#OPENSTREETMAP 🌐\")\n",
211+
" geojson_file = mr.File(label=\"Upload GeoJSON file for processing\", max_file_size=\"100MB\")\n",
188212
" place_long = mr.Text(value=\"\", label=\"Place longitude: \", rows=1)\n",
189213
" place_lat = mr.Text(value=\"\", label=\"Place latitude: \", rows=1)\n",
190214
" basic_zoom = mr.Slider(value=15, label='Basic map zoom (less = more info on the map): ', min=1, max=20)\n",
191215
" add_datasets = mr.Checkbox(value=False, label=\"View additional maps (for interactive map only)\")\n",
192216
" dual_maps = mr.Checkbox(value=False, label=\"Enter dual maps mode (for interactive map only)\")\n",
193217
" osm_analysis = mr.Checkbox(value=False, label=\"Open OSM analysis menu\")\n",
218+
" lat = place_lat.value\n",
219+
" long = place_long.value\n",
194220
" \n",
195221
" try:\n",
196-
" map_folium = folium.Map(location=[place_lat.value, place_long.value], zoom_start=basic_zoom.value)\n",
197-
"\n",
222+
" map_folium = folium.Map(location=[lat, long], zoom_start=basic_zoom.value)\n",
223+
" if geojson_file.filepath is not None:\n",
224+
" try:\n",
225+
" geojson = open(geojson_file.filepath)\n",
226+
" geojson_info = json.load(geojson)\n",
227+
" coordinates = geojson_info['features'][0]['geometry']['coordinates']\n",
228+
" folium.GeoJson(geojson_info, name='geojson').add_to(map_folium)\n",
229+
" except IndexError as error:\n",
230+
" print(Fore.RED + '[GeoJSON file error] - {}'.format(str(error)))\n",
231+
" else:\n",
232+
" pass\n",
233+
" \n",
198234
" if add_datasets.value:\n",
199235
" op.additional_datasets(map_folium)\n",
200236
"\n",
@@ -216,9 +252,7 @@
216252
" map_size = mr.Slider(value=15, label='Map size (NxN):', min=1, max=20)\n",
217253
" place_delta = mr.Text(value=\"0.1\", label=\"DELTA (default is 0.1): \", rows=1)\n",
218254
" g = geocoder.osm([place_lat.value, place_long.value], method='reverse')\n",
219-
" start = str(g).find('[') + 20\n",
220-
" end = str(g).rfind(']')\n",
221-
" mr.Markdown(text = \"**PLACE NAME: {}**\".format(str(g)[start:end]))\n",
255+
" mr.Markdown(text = \"**PLACE NAME: {}**\".format(str(g)))\n",
222256
" #g.json for more information\n",
223257
" op.map_plotting(map_size, place_long.value, place_lat.value, place_delta.value)\n",
224258
"\n",

0 commit comments

Comments
 (0)