Skip to content

Commit

Permalink
Updated GAIA.ipynb to 0.6b
Browse files Browse the repository at this point in the history
  • Loading branch information
OSINT-TECHNOLOGIES committed Feb 15, 2024
1 parent 2489eeb commit 7d242f7
Showing 1 changed file with 89 additions and 107 deletions.
196 changes: 89 additions & 107 deletions GAIA.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"# LIBRARIES IMPORT\n",
"import mercury as mr\n",
"import ee\n",
"import geemap.foliumap as geemap\n",
"import eefolium as geemap\n",
"import os\n",
"import datetime\n",
"import webbrowser\n",
Expand Down Expand Up @@ -60,26 +60,12 @@
"handler.setFormatter(formatter)\n",
"logger.addHandler(handler)\n",
"\n",
"mr.Markdown(text = '**🌎 GAIA - Geospatial & Aerial Images Analyser [BETA] 🌎**')\n",
"mr.Markdown(text = '**🌎 This program solution is not final and some details are potentially to be changed 🌎**')\n",
"mr.Markdown(text = '**🌏 Current version - 0.51b 🌏**')\n",
"mr.Markdown(text = '**🌎 GAIA - Geospatial & Aerial Images Analyser [BETA] 🌎 Not a final program solution, something might be changed 🌎 Current version - 0.6b 🌏**')\n",
"\n",
"text = 'OSINT-TECHNOLOGIES'\n",
"text_params = {\n",
" 'fontsize': 10,\n",
" 'fontcolor': 'black',\n",
" 'bold': True,\n",
" 'padding': '3px',\n",
" 'background': True,\n",
" 'bg_color': 'white',\n",
" 'border_radius': '1px',\n",
" 'position': 'bottomleft',\n",
"}\n",
"sources_list = [\"GAIA HUB\", \"Combined Cartography and Satellite Imagery Module\"]\n",
"control_panel_choice = mr.Select(value=\"GAIA HUB\", choices=sources_list, label=\"Tabs 🔍:\")\n",
"\n",
"sources_list = [\"Welcome to GAIA\", \"Google EE\", \"OpenStreetMap\"]\n",
"control_panel_choice = mr.Select(value=\"Welcome to GAIA\", choices=sources_list, label=\"Choose the source control panel 🔍\")\n",
"\n",
"app = mr.App(title=\"GAIA v0.51b [BETA] 🌐\",\n",
"app = mr.App(title=\"GAIA v0.6b [BETA] 🌐\",\n",
" description=\"Open-Source Geospatial & Aerial Images Analyser\",\n",
" show_code=False,\n",
" show_prompt=False,\n",
Expand All @@ -98,14 +84,16 @@
},
"outputs": [],
"source": [
"if control_panel_choice.value == \"Welcome to GAIA\":\n",
"if control_panel_choice.value == \"GAIA HUB\":\n",
" current_directory = os.getcwd()\n",
" cache_path = current_directory + \"\\cache\"\n",
" logs_path = current_directory + \"\\gee\\gaia-gee-errors.log\"\n",
"\n",
" ee_reg = mr.Button(label=\"Create GEE account\")\n",
" ee_service_acc = mr.Button(label=\"Create & Manage GEE service account\")\n",
" clr_cache_and_logs = mr.Button(label=\"Clear GAIA cache folder\")\n",
" \n",
" \n",
" mr.Markdown('**PROGRAM DETAILS**')\n",
" print(Fore.GREEN + \"Current GAIA directory path: {}\".format(current_directory))\n",
" print(Fore.GREEN + f\"The size of the logs file is {os.path.getsize(logs_path) / (1024 * 1024)} MB.\")\n",
Expand All @@ -124,8 +112,7 @@
" print(Fore.RED + \"Sorry, but cache folder was not found in GAIA directory. You can track this folder's volume in the line above\")\n",
"\n",
" print('\\n'*2)\n",
" txtr.ee_guide_read()\n",
" txtr.osm_guide_read()"
" txtr.ee_guide_read()"
]
},
{
Expand All @@ -136,9 +123,9 @@
},
"outputs": [],
"source": [
"# GOOGLE EE PROCESSING\n",
"# OSM+GEE PROCESSING\n",
"\n",
"if control_panel_choice.value == \"Google EE\":\n",
"if control_panel_choice.value == \"Combined Cartography and Satellite Imagery Module\":\n",
" if str((cec.service_acc_filename).rstrip()) not in os.listdir():\n",
" print(Fore.RED + '[GEE file/directory missing error]. Your EE credentials .JSON file was not found in GAIA directory')\n",
" mr.Stop()\n",
Expand All @@ -148,29 +135,53 @@
" credentials = ee.ServiceAccountCredentials(service_account, key_file)\n",
" ee.Initialize(credentials)\n",
"\n",
" geojson_file = mr.File(label=\"Upload GeoJSON file for processing\", max_file_size=\"100MB\")\n",
" ds_info = mr.Checkbox(value=False, label='Show datasets knowledge base')\n",
"\n",
" date_one = mr.Text(value=\"2022-01-01\", label=\"Enter start date (format YYYY-MM-DD)\", rows=1)\n",
" date_two = mr.Text(value=\"2022-01-02\", label=\"Enter final date (format YYYY-MM-DD)\", rows=1)\n",
"\n",
" max_cloud_covering = mr.Slider(value=80, label='Max cloud cover (%, may affect datasets quality)', min=0, max=100)\n",
" datasets_landsat = mr.Checkbox(value=False, label=\"Show Landsat datasets\")\n",
" datasets_sentinel = mr.Checkbox(value=False, label=\"Show Sentinel datasets\")\n",
" datasets_modis = mr.Checkbox(value=False, label=\"Show MODIS datasets\")\n",
" datasets_other = mr.Checkbox(value=False, label='Show other datasets')\n",
" manual_input = mr.Checkbox(value=False, label='Open custom GEE dataset menu')\n",
"\n",
" selected_datasets = mr.MultiSelect(label=\"Select datasets\",\n",
" value=[],\n",
" choices=[\"All Landsat datasets\", \"All Sentinel datasets\", \"All MODIS datasets\", \"All other datasets\", \"Landsat 7 SR\", \"Landsat 8 SR\", \"Landsat 8 TOA\",\n",
" \"Landsat 9 RAW\", \"Landsat 9 TOA\", \"Landsat 9 SR\", \"Sentinel 2 MSI TOA\", \"Sentinel 2 MSI SR\", \"Sentinel 5P Cloud\",\n",
" \"MODIS Snowcover\", \"MODIS TSR\", \"MODIS TTA&FD\", \"ALOS TD\", \"NASA FIRMS\"])\n",
" \n",
" manual_input = mr.Checkbox(value=False, label='Open custom GEE dataset menu')\n",
" add_datasets = mr.Checkbox(value=False, label=\"View additional cartography maps\")\n",
" mini_map = mr.Checkbox(value=False, label='Show mini map')\n",
"\n",
" m = geemap.Map()\n",
" m.add_basemap('HYBRID')\n",
" m.add_basemap('TERRAIN')\n",
" m.add_basemap('TERRAIN') \n",
" \n",
" if mini_map.value:\n",
" plugins.MiniMap().add_to(m)\n",
" \n",
"\n",
" if geojson_file.filepath is not None:\n",
" try:\n",
" geojson = open(geojson_file.filepath)\n",
" geojson_info = json.load(geojson)\n",
" coordinates = geojson_info['features'][0]['geometry']['coordinates']\n",
" folium.GeoJson(geojson_info, name='geojson').add_to(m)\n",
" except IndexError as error:\n",
" print(Fore.RED + '[OSM GeoJSON file error] - {}'.format(str(error)))\n",
" else:\n",
" pass\n",
"\n",
" if add_datasets.value:\n",
" op.additional_datasets(m)\n",
" op.map_layers(m)\n",
"\n",
" landsat = l_init.LandsatInitialization(m, date_one, date_two, max_cloud_covering)\n",
" sentinel = s_init.SentinelInitialization(m, date_one, date_two, max_cloud_covering)\n",
" modis = m_init.ModisInitialization(m, date_one, date_two, max_cloud_covering)\n",
" others = o_init.OthersInitialization(m, date_one, date_two)\n",
"\n",
" try:\n",
" if datasets_landsat.value:\n",
" landsat = l_init.LandsatInitialization(m, date_one, date_two, max_cloud_covering)\n",
" if \"All Landsat datasets\" in selected_datasets.value:\n",
" with concurrent.futures.ThreadPoolExecutor() as landsat_caller:\n",
" landsat_caller.submit(landsat.ls7sr_init)\n",
" landsat_caller.submit(landsat.ls8toa_init)\n",
Expand All @@ -180,26 +191,54 @@
" landsat_caller.submit(landsat.ls9rawtc_init)\n",
" landsat_caller.submit(landsat.ls9toatc_init)\n",
" \n",
" if datasets_sentinel.value:\n",
" sentinel = s_init.SentinelInitialization(m, date_one, date_two, max_cloud_covering)\n",
" if \"All Sentinel datasets\" in selected_datasets.value:\n",
" with concurrent.futures.ThreadPoolExecutor() as sentinel_caller:\n",
" sentinel_caller.submit(sentinel.sen2msisr_init)\n",
" sentinel_caller.submit(sentinel.sen2msitoa_init)\n",
" sentinel_caller.submit(sentinel.sen5pc_init) \n",
" sentinel_caller.submit(sentinel.sen5pc_init)\n",
"\n",
" if datasets_modis.value:\n",
" modis = m_init.ModisInitialization(m, date_one, date_two, max_cloud_covering)\n",
" if \"All MODIS datasets\" in selected_datasets.value:\n",
" with concurrent.futures.ThreadPoolExecutor() as modis_caller:\n",
" modis_caller.submit(modis.modissc_init)\n",
" modis_caller.submit(modis.modistsr_init)\n",
" modis_caller.submit(modis.modistta_init) \n",
" modis_caller.submit(modis.modistta_init)\n",
"\n",
" if datasets_other.value:\n",
" others = o_init.OthersInitialization(m, date_one, date_two) \n",
" if \"All other datasets\" in selected_datasets.value: \n",
" with concurrent.futures.ThreadPoolExecutor() as others_caller:\n",
" others_caller.submit(others.firms_init)\n",
" others_caller.submit(others.alostd_init)\n",
"\n",
" if \"Landsat 7 SR\" in selected_datasets.value:\n",
" landsat.ls7sr_init()\n",
" if \"Landsat 8 TOA\" in selected_datasets.value:\n",
" landsat.ls8toa_init()\n",
" if \"Landsat 8 RAW\" in selected_datasets.value:\n",
" landsat.ls8rawtc_init()\n",
" if \"Landsat 8 SR\" in selected_datasets.value:\n",
" landsat.ls8sr_init()\n",
" if \"Landsat 9 SR\" in selected_datasets.value:\n",
" landsat.ls9_init()\n",
" if \"Landsat 9 RAW\" in selected_datasets.value:\n",
" landsat.ls9rawtc_init()\n",
" if \"Landsat 9 TOA\" in selected_datasets.value:\n",
" landsat.ls9toatc_init()\n",
" if \"Sentinel 2 MSI SR\" in selected_datasets.value:\n",
" sentinel.sen2msisr_init()\n",
" if \"Sentinel 2 MSI TOA\" in selected_datasets.value:\n",
" sentinel.sen2msitoa_init()\n",
" if \"Sentinel 5P Cloud\" in selected_datasets.value:\n",
" sentinel.sen5pc_init()\n",
" if \"MODIS Snowcover\" in selected_datasets.value:\n",
" modis.modissc_init()\n",
" if \"MODIS TSR\" in selected_datasets.value:\n",
" modis.modistsr_init()\n",
" if \"ALOS TD\" in selected_datasets.value:\n",
" others.alostd_init()\n",
" if \"NASA FIRMS\" in selected_datasets.value:\n",
" others.firms_init()\n",
" if \"MODIS TTA&FD\" in selected_datasets.value:\n",
" modis.modistta_init()\n",
" \n",
" except ee.EEException as error:\n",
" print(Fore.RED + '[GEE map plotting/initialization error] - {}'.format(str(error)))\n",
" logger.error(error)\n",
Expand All @@ -215,10 +254,8 @@
" print(Fore.RED + '[GEE map plotting/initialization error] - {}'.format(str(error)))\n",
" logger.error(error)\n",
" pass\n",
"\n",
" m.add_text(text, **text_params)\n",
" \n",
" mr.Markdown(text = \"#GOOGLE EARTH ENGINE MAP 🌐\")\n",
" mr.Markdown(text = \"#CARTOGRAPHY AND SATELLITE IMAGERY MODULE MAP 🌐\")\n",
" mr.Markdown(text = \"**DATASETS TIME PERIOD: from {} to {}**\".format(date_one.value, date_two.value))\n",
" \n",
" if manual_input.value:\n",
Expand All @@ -238,72 +275,17 @@
" plt.axis('off')\n",
" plt.show()\n",
" txtr.ds_info_read()\n",
"\n",
" plugins.Geocoder(\n",
" position='bottomleft',\n",
" force_separate_button=True\n",
" ).add_to(m)\n",
" \n",
" draw = Draw(export=True)\n",
" draw.add_to(m) \n",
" m.addLayerControl()\n",
" display(m)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# OSM PROCESSING\n",
"\n",
"if control_panel_choice.value == \"OpenStreetMap\":\n",
" mr.Markdown(text = \"#OPENSTREETMAP 🌐\")\n",
" geojson_file = mr.File(label=\"Upload GeoJSON file for processing\", max_file_size=\"100MB\")\n",
" basic_zoom = mr.Slider(value=15, label='Basic map zoom (less = more info on the map): ', min=1, max=20)\n",
" add_datasets = mr.Checkbox(value=False, label=\"View additional maps\")\n",
" dual_maps = mr.Checkbox(value=False, label=\"Enter dual maps mode\")\n",
" mini_map = mr.Checkbox(value=False, label=\"Show mini map\")\n",
"\n",
" try:\n",
" map_folium = folium.Map(zoom_start=basic_zoom.value)\n",
" if geojson_file.filepath is not None:\n",
" try:\n",
" geojson = open(geojson_file.filepath)\n",
" geojson_info = json.load(geojson)\n",
" coordinates = geojson_info['features'][0]['geometry']['coordinates']\n",
" folium.GeoJson(geojson_info, name='geojson').add_to(map_folium)\n",
" except IndexError as error:\n",
" print(Fore.RED + '[OSM GeoJSON file error] - {}'.format(str(error)))\n",
" else:\n",
" pass\n",
" \n",
" if add_datasets.value:\n",
" op.additional_datasets(map_folium)\n",
"\n",
" op.map_layers(map_folium)\n",
" \n",
" if dual_maps.value:\n",
" map_folium = folium.plugins.DualMap(zoom_start=basic_zoom.value)\n",
" op.dual_maps_processing(map_folium)\n",
" else:\n",
" folium.LayerControl().add_to(map_folium)\n",
"\n",
" draw = Draw(export=True)\n",
" draw.add_to(map_folium)\n",
"\n",
" plugins.Geocoder(\n",
" position='bottomleft',\n",
" force_separate_button=True\n",
" ).add_to(map_folium)\n",
"\n",
" plugins.Fullscreen(\n",
" position='topleft',\n",
" force_separate_button=False\n",
" ).add_to(map_folium)\n",
"\n",
" if mini_map.value:\n",
" plugins.MiniMap().add_to(map_folium)\n",
" display(map_folium)\n",
" \n",
" except (ValueError, TypeError):\n",
" print('OSM coordinates were not entered (or entered in incorrect type) or they are within geographical boundaries')"
]
}
],
"metadata": {
Expand Down

0 comments on commit 7d242f7

Please sign in to comment.