|
16 | 16 | "import logging\n",
|
17 | 17 | "import geocoder\n",
|
18 | 18 | "import folium\n",
|
| 19 | + "import json\n", |
| 20 | + "import matplotlib.pyplot as plt\n", |
19 | 21 | "from folium.plugins import Draw\n",
|
20 | 22 | "from ipyleaflet import *\n",
|
21 | 23 | "from colorama import Fore\n",
|
| 24 | + "from PIL import Image\n", |
22 | 25 | "\n",
|
23 | 26 | "# PROGRAM MODULES IMPORT\n",
|
24 | 27 | "sys.path.insert(0, 'gee//modules//') # gee modules path\n",
|
|
53 | 56 | "\n",
|
54 | 57 | "mr.Markdown(text = '**🌎 GAIA - Geospatial & Aerial Images Analyser [BETA] 🌎**')\n",
|
55 | 58 | "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", |
57 | 60 | "\n",
|
58 | 61 | "text = 'OSINT-TECHNOLOGIES'\n",
|
59 | 62 | "text_params = {\n",
|
|
68 | 71 | "}\n",
|
69 | 72 | "\n",
|
70 | 73 | "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", |
72 | 75 | "\n",
|
73 |
| - "app = mr.App(title=\"GAIA v0.4b [BETA] 🌐\",\n", |
| 76 | + "app = mr.App(title=\"GAIA v0.41b [BETA] 🌐\",\n", |
74 | 77 | " description=\"Open-Source Geospatial & Aerial Images Analyser\",\n",
|
75 | 78 | " show_code=False,\n",
|
76 | 79 | " show_prompt=False,\n",
|
|
92 | 95 | "# GOOGLE EE PROCESSING\n",
|
93 | 96 | "\n",
|
94 | 97 | "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", |
115 | 98 | " if str((cec.service_acc_filename).rstrip()) not in os.listdir():\n",
|
116 | 99 | " print(Fore.RED + '[File/directory missing error]. Your EE credentials .JSON file was not found in GAIA directory')\n",
|
117 | 100 | " mr.Stop()\n",
|
|
120 | 103 | " service_account = (cec.service_acc_mail).rstrip()\n",
|
121 | 104 | " credentials = ee.ServiceAccountCredentials(service_account, key_file)\n",
|
122 | 105 | " ee.Initialize(credentials)\n",
|
123 |
| - "\n", |
| 106 | + " \n", |
124 | 107 | " m = geemap.Map()\n",
|
125 |
| - " m.add_text(text, **text_params)\n", |
126 | 108 | " m.add_basemap('SATELLITE')\n",
|
127 | 109 | " m.add_basemap('TERRAIN')\n",
|
128 | 110 | " 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", |
130 | 124 | " 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", |
137 | 125 | " if datasets_landsat.value:\n",
|
138 | 126 | " l_init.landsat_initialization(m, date_one, date_two, max_cloud_covering)\n",
|
139 | 127 | " \n",
|
140 | 128 | " if datasets_sentinel.value:\n",
|
141 | 129 | " s_init.sentinel_initialization(m, date_one, date_two, max_cloud_covering)\n",
|
142 |
| - " \n", |
| 130 | + " \n", |
143 | 131 | " if datasets_modis.value:\n",
|
144 | 132 | " m_init.modis_initialization(m, date_one, date_two)\n",
|
145 |
| - " \n", |
| 133 | + " \n", |
146 | 134 | " 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", |
149 | 136 | " except ee.EEException as error:\n",
|
150 | 137 | " print(Fore.RED + '[Map plotting/initialization error] - {}'.format(str(error)))\n",
|
151 | 138 | " logger.error(error)\n",
|
152 | 139 | " 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", |
153 | 159 | " \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", |
154 | 165 | " mr.Markdown(text = \"#GOOGLE EARTH ENGINE MAP 🌐\")\n",
|
155 | 166 | " mr.Markdown(text = \"**DATASETS TIME PERIOD: from {} to {}**\".format(date_one.value, date_two.value))\n",
|
156 | 167 | " \n",
|
157 | 168 | " if manual_input.value:\n",
|
158 | 169 | " mr.Markdown(text = \"**CUSTOM DATASETS TIME PERIOD: from {} to {}**\".format(date_one_custom.value, date_two_custom.value))\n",
|
159 | 170 | " \n",
|
160 | 171 | " 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", |
161 | 184 | " txtr.ds_info_read()\n",
|
162 |
| - " \n", |
163 |
| - " if ee_user_guide.clicked:\n", |
| 185 | + "\n", |
| 186 | + " if ee_user_guide.value:\n", |
164 | 187 | " txtr.ee_guide_read()\n",
|
165 | 188 | " \n",
|
166 | 189 | " download_dir = os.path.join(os.path.expanduser('~'), 'Downloads')\n",
|
|
185 | 208 | "\n",
|
186 | 209 | "if control_panel_choice.value == \"OpenStreetMap\":\n",
|
187 | 210 | " mr.Markdown(text = \"#OPENSTREETMAP 🌐\")\n",
|
| 211 | + " geojson_file = mr.File(label=\"Upload GeoJSON file for processing\", max_file_size=\"100MB\")\n", |
188 | 212 | " place_long = mr.Text(value=\"\", label=\"Place longitude: \", rows=1)\n",
|
189 | 213 | " place_lat = mr.Text(value=\"\", label=\"Place latitude: \", rows=1)\n",
|
190 | 214 | " basic_zoom = mr.Slider(value=15, label='Basic map zoom (less = more info on the map): ', min=1, max=20)\n",
|
191 | 215 | " add_datasets = mr.Checkbox(value=False, label=\"View additional maps (for interactive map only)\")\n",
|
192 | 216 | " dual_maps = mr.Checkbox(value=False, label=\"Enter dual maps mode (for interactive map only)\")\n",
|
193 | 217 | " osm_analysis = mr.Checkbox(value=False, label=\"Open OSM analysis menu\")\n",
|
| 218 | + " lat = place_lat.value\n", |
| 219 | + " long = place_long.value\n", |
194 | 220 | " \n",
|
195 | 221 | " 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", |
198 | 234 | " if add_datasets.value:\n",
|
199 | 235 | " op.additional_datasets(map_folium)\n",
|
200 | 236 | "\n",
|
|
216 | 252 | " map_size = mr.Slider(value=15, label='Map size (NxN):', min=1, max=20)\n",
|
217 | 253 | " place_delta = mr.Text(value=\"0.1\", label=\"DELTA (default is 0.1): \", rows=1)\n",
|
218 | 254 | " 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", |
222 | 256 | " #g.json for more information\n",
|
223 | 257 | " op.map_plotting(map_size, place_long.value, place_lat.value, place_delta.value)\n",
|
224 | 258 | "\n",
|
|
0 commit comments