{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":64733,"databundleVersionId":7762802,"sourceType":"competition"},{"sourceId":7752763,"sourceType":"datasetVersion","datasetId":4533016}],"dockerImageVersionId":30664,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"Published on March 03, 2024. By Marília Prata, mpwolke","metadata":{}},{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport seaborn as sns\nfrom matplotlib import pyplot as plt\n\nfrom tqdm import tqdm\nimport matplotlib.pyplot as plt\n\nimport plotly.graph_objects as go\nimport plotly.offline as py\nimport plotly.express as px\nfrom plotly.offline import iplot\n\n#Ignore warnings\nimport warnings\nwarnings.filterwarnings('ignore')\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_kg_hide-input":true,"_kg_hide-output":true,"execution":{"iopub.status.busy":"2024-03-03T18:31:06.532997Z","iopub.execute_input":"2024-03-03T18:31:06.535383Z"},"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"![](https://www.lirmm.fr/arith18/img/LIRMMlogo_complet.png)https://www.lirmm.fr/","metadata":{}},{"cell_type":"markdown","source":"#Merci à tous Organisateurs et Contributeurs:\n\nLukas Picek, INRIA, LIRMM, Montpellier\n\nChristophe Botella, INRIA, LIRMM, Montpellier\n\nDiego Marcos, INRIA , Montpellier\n\nThéo Larcher, INRIA, LIRMM, Montpellier\n\nJoachim Estopinan, INRIA, LIRMM, Montpellier\n\nCésar Leblanc, INRIA, LIRMM, Montpellier\n\nMaximilien Servajean, Université Paul Valéry, LIRMM, Montpellier\n\nAlexis Joly, INRIA, LIRMM, Montpellier\n\nhttps://www.kaggle.com/competitions/geolifeclef-2024/overview","metadata":{}},{"cell_type":"markdown","source":"#Started 12:54 till 13:14 to load the Dataset. The Climate Zip till 13:35  Upload on Kaggle 15:24\n\nNotebook running for 3h:55m and the session failed to saved the draft : )","metadata":{}},{"cell_type":"code","source":"import os, sys, random, gc, math, glob, time, pathlib\nimport numpy as np\nimport pandas as pd\nimport io, timeit, os, gc, pickle, psutil\nimport warnings\nimport cv2\n#import gdal\n#import osgeo\nimport json\nimport rasterio\nfrom rasterio.windows import Window","metadata":{"execution":{"iopub.status.busy":"2024-03-03T16:14:20.914144Z","iopub.execute_input":"2024-03-03T16:14:20.914539Z","iopub.status.idle":"2024-03-03T16:14:21.782158Z","shell.execute_reply.started":"2024-03-03T16:14:20.914508Z","shell.execute_reply":"2024-03-03T16:14:21.781039Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#I don't need the snippet below since I downloaded Climate Dataset on Seafile\n\nhttps://lab.plantnet.org/seafile/d/bdb829337aa44a9489f6/","metadata":{}},{"cell_type":"code","source":"!python download.py --data output --raster --presence-only --Climate","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Climate - EnvironmentalRasters\n\nMONTHLY CLIMATIC RASTERS\n\n\"Four climatic variables computed monthly (mean, minimum and maximum temperature, and total precipitation) from January 2000 to December 2019, yielding 960 low-resolution rasters covering Europe.\"\n\n\"Format1: CSV files, one per raster referenced through the \"surveyId\".\nFormat2: TimeSeries-Cubes - Above mentioned CSV aggregated into 3d tensors with axis as YEAR, QUATER, RASTER-TYPE.\nResolution: ~1 kilometer\nSource: Chelsa\nAccess: /EnvironmentalRasters/Climate/Climatic_Monthly_2000-2019\nEnvironmental rasters\nFor each observation, we provide additional environmental data such as GeoTIFF rasters and scalar values already extracted from the rasters. We provide CSV files, one per band raster type, i.e., Climate, Elevation, Human Footprint, LandCover, and SoilGrids.\n\nBIOCLIMATIC RASTERS:\n\n19 low-resolution rasters covering Europe; commonly used in species distribution modeling. Provided in longitude/latitude coordinates (WGS84).\"\n\nFormat: GeoTIFF files with compression and CSV file with extracted values.\nResolution: 30 arcsec (~ 1 kilometer)\nSource: Landsat remote sensing data pre-processed by the Ecodatacube platform\nAccess: /EnvironmentalRasters/Climate/BioClimatic_Average_1981-2010\n\nhttps://www.kaggle.com/competitions/geolifeclef-2024/data","metadata":{}},{"cell_type":"code","source":"import rasterio as rio\nimport folium\nimport tifffile as tiff","metadata":{"execution":{"iopub.status.busy":"2024-03-03T19:21:56.669843Z","iopub.execute_input":"2024-03-03T19:21:56.670249Z","iopub.status.idle":"2024-03-03T19:21:56.675124Z","shell.execute_reply.started":"2024-03-03T19:21:56.670220Z","shell.execute_reply":"2024-03-03T19:21:56.674185Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by JyeSR https://www.kaggle.com/jyesawtellrickson/data-measurement-levels\n\nfrom skimage.io import imread\nimage = imread('/kaggle/input/climateclef/Climate/BioClimatic_Average_1981-2010/bio1.tif')\nprint (image.shape)\nplt.imshow(image[:,:], cmap = 'terrain')#it was [:,:,0]\nplt.axes = False\nplt.title(\"Raster Bioclimatic 1981-2020 Bio1 \");","metadata":{"execution":{"iopub.status.busy":"2024-03-03T19:22:14.585352Z","iopub.execute_input":"2024-03-03T19:22:14.585762Z","iopub.status.idle":"2024-03-03T19:22:18.565668Z","shell.execute_reply.started":"2024-03-03T19:22:14.585729Z","shell.execute_reply":"2024-03-03T19:22:18.564687Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by JyeSR https://www.kaggle.com/jyesawtellrickson/data-measurement-levels\n\nfrom skimage.io import imread\nimage = imread('/kaggle/input/climateclef/Climate/BioClimatic_Average_1981-2010/bio19.tif')\nprint (image.shape)\nplt.imshow(image[:,:], cmap = 'viridis')#it was [:,:,0]\nplt.axes = False\nplt.title(\"Raster Bioclimatic 1981-2020 Bio19\");","metadata":{"execution":{"iopub.status.busy":"2024-03-03T19:23:18.259076Z","iopub.execute_input":"2024-03-03T19:23:18.259466Z","iopub.status.idle":"2024-03-03T19:23:24.299112Z","shell.execute_reply.started":"2024-03-03T19:23:18.259437Z","shell.execute_reply":"2024-03-03T19:23:24.297993Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by JyeSR https://www.kaggle.com/jyesawtellrickson/data-measurement-levels\n\nfrom skimage.io import imread\nimage = imread('/kaggle/input/climateclef/Climate/BioClimatic_Average_1981-2010/bio6.tif')\nprint (image.shape)\nplt.imshow(image[:,:], cmap = 'plasma')#it was [:,:,0]\nplt.axes = False\nplt.title(\"Raster Bioclimatic 1981-2020 Bio6\");","metadata":{"execution":{"iopub.status.busy":"2024-03-03T19:24:19.313840Z","iopub.execute_input":"2024-03-03T19:24:19.314985Z","iopub.status.idle":"2024-03-03T19:24:23.201881Z","shell.execute_reply.started":"2024-03-03T19:24:19.314948Z","shell.execute_reply":"2024-03-03T19:24:23.200864Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by JyeSR https://www.kaggle.com/jyesawtellrickson/data-measurement-levels\n\nfrom skimage.io import imread\nimage = imread('/kaggle/input/climateclef/Climate/BioClimatic_Average_1981-2010/bio5.tif')\nprint (image.shape)\nplt.imshow(image[:,:], cmap = 'YlGnBu')#it was [:,:,0]\nplt.axes = False\nplt.title(\"Raster Bioclimatic 1981-2020 Bio6\");","metadata":{"execution":{"iopub.status.busy":"2024-03-03T19:25:37.089217Z","iopub.execute_input":"2024-03-03T19:25:37.089655Z","iopub.status.idle":"2024-03-03T19:25:41.417526Z","shell.execute_reply.started":"2024-03-03T19:25:37.089626Z","shell.execute_reply":"2024-03-03T19:25:41.416447Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by JyeSR https://www.kaggle.com/jyesawtellrickson/data-measurement-levels\n\nfrom skimage.io import imread\nimage = imread('/kaggle/input/climateclef/Climate/BioClimatic_Average_1981-2010/bio2.tif')\nprint (image.shape)\nplt.imshow(image[:,:], cmap = 'Reds')#it was [:,:,0]\nplt.axes = False\nplt.title(\"Raster Bioclimatic 1981-2020 Bio2\");","metadata":{"execution":{"iopub.status.busy":"2024-03-03T19:26:24.820700Z","iopub.execute_input":"2024-03-03T19:26:24.821174Z","iopub.status.idle":"2024-03-03T19:26:29.002640Z","shell.execute_reply.started":"2024-03-03T19:26:24.821126Z","shell.execute_reply":"2024-03-03T19:26:29.001284Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by JyeSR https://www.kaggle.com/jyesawtellrickson/data-measurement-levels\n\nfrom skimage.io import imread\nimage = imread('/kaggle/input/climateclef/Climate/BioClimatic_Average_1981-2010/bio13.tif')\nprint (image.shape)\nplt.imshow(image[:,:], cmap = 'Greens')#it was [:,:,0]\nplt.axes = False\nplt.title(\"Raster Bioclimatic 1981-2020 Bio13\");","metadata":{"execution":{"iopub.status.busy":"2024-03-03T19:27:26.753280Z","iopub.execute_input":"2024-03-03T19:27:26.754402Z","iopub.status.idle":"2024-03-03T19:27:31.499869Z","shell.execute_reply.started":"2024-03-03T19:27:26.754362Z","shell.execute_reply":"2024-03-03T19:27:31.498785Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Unfortunately, I wasn't lucky to open a Climatic Montly 2000-2019. Many are empty.","metadata":{}},{"cell_type":"code","source":"#Code by JyeSR https://www.kaggle.com/jyesawtellrickson/data-measurement-levels\n\nfrom skimage.io import imread\nimage = imread('/kaggle/input/climateclef/Climate/Climatic_Monthly_2000-2019/01_2000_pr.tif')\nprint (image.shape)\nplt.imshow(image[:,:], cmap = 'ocean') #it was [:,:,0] 3D\nplt.axes = False\nplt.title(\"Raster Montly 01_2000\");","metadata":{"execution":{"iopub.status.busy":"2024-03-03T19:22:43.889231Z","iopub.execute_input":"2024-03-03T19:22:43.889683Z","iopub.status.idle":"2024-03-03T19:22:49.333409Z","shell.execute_reply.started":"2024-03-03T19:22:43.889648Z","shell.execute_reply":"2024-03-03T19:22:49.332161Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"DATA_PATH = \"../input/geolifeclef-2024/\"","metadata":{"execution":{"iopub.status.busy":"2024-03-03T16:20:56.758892Z","iopub.execute_input":"2024-03-03T16:20:56.759553Z","iopub.status.idle":"2024-03-03T16:20:56.764900Z","shell.execute_reply.started":"2024-03-03T16:20:56.759519Z","shell.execute_reply":"2024-03-03T16:20:56.763295Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Since everything is huge on this Competition, I'll open just one directory (from Train/RGB)\n\nPA_Train_SatellitePatches_RGB (1 directory), pa_train_patches_rgb (100 directories), 00 (100 directories) and finally 04 (16 files)","metadata":{}},{"cell_type":"code","source":"image_paths = sorted(glob.glob(os.path.join(DATA_PATH, 'PA_Train_SatellitePatches_RGB/pa_train_patches_rgb/00/04/*.jpeg')))","metadata":{"execution":{"iopub.status.busy":"2024-03-03T16:23:54.971022Z","iopub.execute_input":"2024-03-03T16:23:54.971418Z","iopub.status.idle":"2024-03-03T16:23:54.983041Z","shell.execute_reply.started":"2024-03-03T16:23:54.971389Z","shell.execute_reply":"2024-03-03T16:23:54.981914Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f\"Number of images: {len(image_paths)}\")","metadata":{"execution":{"iopub.status.busy":"2024-03-03T16:23:59.962050Z","iopub.execute_input":"2024-03-03T16:23:59.962427Z","iopub.status.idle":"2024-03-03T16:23:59.968369Z","shell.execute_reply.started":"2024-03-03T16:23:59.962399Z","shell.execute_reply":"2024-03-03T16:23:59.967006Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Ihelon https://www.kaggle.com/code/ihelon/illustrations-kumapi390-eda\n\nimage_shapes = {}\n\nfor ind, image_path in enumerate(image_paths):\n    image = cv2.imread(image_path)\n    image_shapes[image.shape] = image_shapes.get(image.shape, 0) + 1\n    \nimage_shapes","metadata":{"execution":{"iopub.status.busy":"2024-03-03T16:24:07.003000Z","iopub.execute_input":"2024-03-03T16:24:07.003387Z","iopub.status.idle":"2024-03-03T16:24:07.163185Z","shell.execute_reply.started":"2024-03-03T16:24:07.003357Z","shell.execute_reply":"2024-03-03T16:24:07.162027Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Ihelon https://www.kaggle.com/code/ihelon/illustrations-kumapi390-eda\n\nn_cols = 4\n\nfor ind, image_path in enumerate(image_paths):\n    image = cv2.imread(image_path)\n    image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)\n    \n    if ind % n_cols == 0:\n        plt.figure(figsize=(16, 5))\n    plt.subplot(1, n_cols, ind % n_cols + 1)\n    plt.imshow(image)\n    plt.axis(\"off\")\n    if ind % n_cols == n_cols - 1:\n        plt.show()","metadata":{"execution":{"iopub.status.busy":"2024-03-03T16:24:13.946103Z","iopub.execute_input":"2024-03-03T16:24:13.946538Z","iopub.status.idle":"2024-03-03T16:24:15.817117Z","shell.execute_reply.started":"2024-03-03T16:24:13.946505Z","shell.execute_reply":"2024-03-03T16:24:15.815959Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#The Huge Len of the file (88987)","metadata":{}},{"cell_type":"code","source":"image_paths2 = sorted(glob.glob(os.path.join(DATA_PATH, 'PA_Train_SatellitePatches_RGB/pa_train_patches_rgb/**/**/*.jpeg')))","metadata":{"execution":{"iopub.status.busy":"2024-03-03T17:53:12.376814Z","iopub.execute_input":"2024-03-03T17:53:12.377275Z","iopub.status.idle":"2024-03-03T17:53:18.475565Z","shell.execute_reply.started":"2024-03-03T17:53:12.377242Z","shell.execute_reply":"2024-03-03T17:53:18.474578Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f\"Number of images: {len(image_paths2)}\")","metadata":{"execution":{"iopub.status.busy":"2024-03-03T17:53:43.734457Z","iopub.execute_input":"2024-03-03T17:53:43.736332Z","iopub.status.idle":"2024-03-03T17:53:43.743627Z","shell.execute_reply.started":"2024-03-03T17:53:43.736278Z","shell.execute_reply":"2024-03-03T17:53:43.742412Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Let's check NIR\n\nPA_Train_SatellitePatches_NIR(1 directories), pa_train_patches_nir(100 directories), 00(100 directories) and 04(16 files).","metadata":{}},{"cell_type":"code","source":"image_paths1 = sorted(glob.glob(os.path.join(DATA_PATH, 'PA_Train_SatellitePatches_NIR/pa_train_patches_nir/00/04/*.jpeg')))","metadata":{"execution":{"iopub.status.busy":"2024-03-03T16:31:25.384354Z","iopub.execute_input":"2024-03-03T16:31:25.384759Z","iopub.status.idle":"2024-03-03T16:31:25.393927Z","shell.execute_reply.started":"2024-03-03T16:31:25.384729Z","shell.execute_reply":"2024-03-03T16:31:25.392899Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Ihelon https://www.kaggle.com/code/ihelon/illustrations-kumapi390-eda\n\nimage_shapes = {}\n\nfor ind, image_path in enumerate(image_paths1):\n    image = cv2.imread(image_path)\n    image_shapes[image.shape] = image_shapes.get(image.shape, 0) + 1\n    \nimage_shapes","metadata":{"execution":{"iopub.status.busy":"2024-03-03T16:34:18.133255Z","iopub.execute_input":"2024-03-03T16:34:18.133652Z","iopub.status.idle":"2024-03-03T16:34:18.289683Z","shell.execute_reply.started":"2024-03-03T16:34:18.133622Z","shell.execute_reply":"2024-03-03T16:34:18.288583Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Ihelon https://www.kaggle.com/code/ihelon/illustrations-kumapi390-eda\n\nn_cols = 4\n\nfor ind, image_path in enumerate(image_paths1):\n    image = cv2.imread(image_path)\n    image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)\n    \n    if ind % n_cols == 0:\n        plt.figure(figsize=(16, 5))\n    plt.subplot(1, n_cols, ind % n_cols + 1)\n    plt.imshow(image)\n    plt.axis(\"off\")\n    if ind % n_cols == n_cols - 1:\n        plt.show()","metadata":{"execution":{"iopub.status.busy":"2024-03-03T16:34:52.981786Z","iopub.execute_input":"2024-03-03T16:34:52.982189Z","iopub.status.idle":"2024-03-03T16:34:54.437183Z","shell.execute_reply.started":"2024-03-03T16:34:52.982159Z","shell.execute_reply":"2024-03-03T16:34:54.435977Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#NIR files Len (88987)","metadata":{}},{"cell_type":"code","source":"image_paths3 = sorted(glob.glob(os.path.join(DATA_PATH, 'PA_Train_SatellitePatches_NIR/pa_train_patches_nir/**/**/*.jpeg')))","metadata":{"execution":{"iopub.status.busy":"2024-03-03T17:55:46.172140Z","iopub.execute_input":"2024-03-03T17:55:46.172560Z","iopub.status.idle":"2024-03-03T17:55:51.737590Z","shell.execute_reply.started":"2024-03-03T17:55:46.172531Z","shell.execute_reply":"2024-03-03T17:55:51.736309Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f\"Number of images: {len(image_paths3)}\")","metadata":{"execution":{"iopub.status.busy":"2024-03-03T17:56:10.521971Z","iopub.execute_input":"2024-03-03T17:56:10.523017Z","iopub.status.idle":"2024-03-03T17:56:10.528985Z","shell.execute_reply.started":"2024-03-03T17:56:10.522979Z","shell.execute_reply":"2024-03-03T17:56:10.527596Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Opening a Time Series-Cubes pt File. However, I've No clue about what to make with those Pt files.","metadata":{}},{"cell_type":"code","source":"#By StackOverflow https://stackoverflow.com/questions/71533654/open-and-read-pt-file-using-python-code-by-pytorch\n\nimport torch\n\n# Load the file\npt_file = torch.load(\"../input/geolifeclef-2024/TimeSeries-Cubes/GLC24-PA-train-bioclimatic_monthly/GLC24-PA-train-bioclimatic_monthly_1000012_cube.pt\")\n\n# Print the head of the file\nprint(pt_file[:5])","metadata":{"execution":{"iopub.status.busy":"2024-03-03T17:10:09.307916Z","iopub.execute_input":"2024-03-03T17:10:09.308304Z","iopub.status.idle":"2024-03-03T17:10:09.458814Z","shell.execute_reply.started":"2024-03-03T17:10:09.308274Z","shell.execute_reply":"2024-03-03T17:10:09.456672Z"},"_kg_hide-output":true,"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = pd.read_csv(\"../input/geolifeclef-2024/GLC24_PA_metadata_train.csv\", sep=\",\")\n\ntrain.tail()","metadata":{"execution":{"iopub.status.busy":"2024-03-03T17:19:04.081481Z","iopub.execute_input":"2024-03-03T17:19:04.081907Z","iopub.status.idle":"2024-03-03T17:19:07.426382Z","shell.execute_reply.started":"2024-03-03T17:19:04.081869Z","shell.execute_reply":"2024-03-03T17:19:07.425275Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Sınıflara ait örnek sayılarının grafikle gösterimi \nfig, ax=plt.subplots(1,2,figsize=(30,30))\nplt.xticks(rotation=45, fontsize=12)\nsns.countplot(x='region', data=train, ax=ax[0])\ntrain['region'].value_counts().plot.pie(autopct=\"%1.1f%%\", ax=ax[1])\nplt.title('European Flora by Regions', fontsize=16);","metadata":{"execution":{"iopub.status.busy":"2024-03-03T17:21:08.767874Z","iopub.execute_input":"2024-03-03T17:21:08.768267Z","iopub.status.idle":"2024-03-03T17:21:11.734332Z","shell.execute_reply.started":"2024-03-03T17:21:08.768238Z","shell.execute_reply":"2024-03-03T17:21:11.733165Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import geopandas as gpd","metadata":{"execution":{"iopub.status.busy":"2024-03-03T17:21:34.681614Z","iopub.execute_input":"2024-03-03T17:21:34.682061Z","iopub.status.idle":"2024-03-03T17:21:34.949244Z","shell.execute_reply.started":"2024-03-03T17:21:34.682025Z","shell.execute_reply":"2024-03-03T17:21:34.948249Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"geom = gpd.points_from_xy(x = train['lon'], y=train['lat'], crs=4326)\ntrain_geo = gpd.GeoDataFrame(train, geometry=geom)","metadata":{"execution":{"iopub.status.busy":"2024-03-03T17:22:50.325490Z","iopub.execute_input":"2024-03-03T17:22:50.325933Z","iopub.status.idle":"2024-03-03T17:24:12.577535Z","shell.execute_reply.started":"2024-03-03T17:22:50.325901Z","shell.execute_reply":"2024-03-03T17:24:12.576678Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#On the previous Notebook I plotted 2 maps by Countries, now I'll try by regions: Alpine region.","metadata":{}},{"cell_type":"code","source":"train_geo_al = train_geo[train_geo['region']=='ALPINE']","metadata":{"execution":{"iopub.status.busy":"2024-03-03T17:25:38.045890Z","iopub.execute_input":"2024-03-03T17:25:38.046279Z","iopub.status.idle":"2024-03-03T17:25:38.328615Z","shell.execute_reply.started":"2024-03-03T17:25:38.046250Z","shell.execute_reply":"2024-03-03T17:25:38.327428Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#SpeciesId 254.0 (tff= two five four)","metadata":{}},{"cell_type":"code","source":"tff = train_geo_al[train_geo_al['speciesId']==254.0]\ntff.head()","metadata":{"execution":{"iopub.status.busy":"2024-03-03T17:26:47.633044Z","iopub.execute_input":"2024-03-03T17:26:47.633479Z","iopub.status.idle":"2024-03-03T17:26:47.657605Z","shell.execute_reply.started":"2024-03-03T17:26:47.633445Z","shell.execute_reply":"2024-03-03T17:26:47.656611Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Which Countries have Alpine region (species 254.0)","metadata":{}},{"cell_type":"code","source":"tff[\"country\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-03-03T17:31:16.996357Z","iopub.execute_input":"2024-03-03T17:31:16.996839Z","iopub.status.idle":"2024-03-03T17:31:17.008462Z","shell.execute_reply.started":"2024-03-03T17:31:16.996786Z","shell.execute_reply":"2024-03-03T17:31:17.006452Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tff['country'].value_counts(dropna=False).plot(kind='barh', color=['green', 'red', 'purple', 'orange', 'blue'], title='Count by 254.0 SpeciesId (Countries Alpine Region)');","metadata":{"execution":{"iopub.status.busy":"2024-03-03T17:34:13.636027Z","iopub.execute_input":"2024-03-03T17:34:13.636425Z","iopub.status.idle":"2024-03-03T17:34:13.945031Z","shell.execute_reply.started":"2024-03-03T17:34:13.636397Z","shell.execute_reply":"2024-03-03T17:34:13.943877Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Our Sample has 67 ","metadata":{}},{"cell_type":"code","source":"country_params = dict(column=\"country\", tooltip=True, popup=True, cmap=['green', 'red', 'purple', 'orange', 'blue'], marker_kwds=dict(radius=3.5, fill=True), style_kwds=dict(stroke=False))\ntff.sample(60).explore(**country_params)","metadata":{"execution":{"iopub.status.busy":"2024-03-03T17:48:31.476108Z","iopub.execute_input":"2024-03-03T17:48:31.476527Z","iopub.status.idle":"2024-03-03T17:48:31.552483Z","shell.execute_reply.started":"2024-03-03T17:48:31.476496Z","shell.execute_reply":"2024-03-03T17:48:31.551555Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Changing Region to Continental","metadata":{}},{"cell_type":"code","source":"train_geo_con = train_geo[train_geo['region']=='CONTINENTAL']","metadata":{"execution":{"iopub.status.busy":"2024-03-03T17:38:33.024938Z","iopub.execute_input":"2024-03-03T17:38:33.025758Z","iopub.status.idle":"2024-03-03T17:38:33.501481Z","shell.execute_reply.started":"2024-03-03T17:38:33.025722Z","shell.execute_reply":"2024-03-03T17:38:33.500456Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#By Rob Mulla https://www.kaggle.com/code/robikscube/sign-language-recognition-eda-twitch-stream\n\nfig, ax = plt.subplots(figsize=(4, 4))\ntrain_geo_con[\"speciesId\"].value_counts().head().sort_values(ascending=True).plot(\n    kind=\"barh\", color='g', ax=ax, title=\"European Flora Species by Continental region\"\n)\nax.set_xlabel(\"Number of Training Examples\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-03-03T17:43:56.013968Z","iopub.execute_input":"2024-03-03T17:43:56.014406Z","iopub.status.idle":"2024-03-03T17:43:56.312430Z","shell.execute_reply.started":"2024-03-03T17:43:56.014377Z","shell.execute_reply":"2024-03-03T17:43:56.311290Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Above SpeciesId 4397.0 seems to have more occurences by Continental Region","metadata":{}},{"cell_type":"code","source":"ftns = train_geo_con[train_geo_con['speciesId']==4397.0]\nftns.head()","metadata":{"execution":{"iopub.status.busy":"2024-03-03T17:44:47.621872Z","iopub.execute_input":"2024-03-03T17:44:47.622268Z","iopub.status.idle":"2024-03-03T17:44:47.655063Z","shell.execute_reply.started":"2024-03-03T17:44:47.622238Z","shell.execute_reply":"2024-03-03T17:44:47.653907Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ftns[\"country\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-03-03T17:47:00.320194Z","iopub.execute_input":"2024-03-03T17:47:00.320631Z","iopub.status.idle":"2024-03-03T17:47:00.334074Z","shell.execute_reply.started":"2024-03-03T17:47:00.320599Z","shell.execute_reply":"2024-03-03T17:47:00.332743Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"country_params = dict(column=\"country\", tooltip=True, popup=True, colormap='purple', marker_kwds=dict(radius=3.5, fill=True), style_kwds=dict(stroke=False))\nftns.sample(12000).explore(**country_params)","metadata":{"execution":{"iopub.status.busy":"2024-03-03T17:50:27.590925Z","iopub.execute_input":"2024-03-03T17:50:27.591388Z","iopub.status.idle":"2024-03-03T17:50:32.175561Z","shell.execute_reply.started":"2024-03-03T17:50:27.591356Z","shell.execute_reply":"2024-03-03T17:50:32.174064Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Trying Boreal Region","metadata":{}},{"cell_type":"code","source":"train_geo_bo = train_geo[train_geo['region']=='BOREAL']","metadata":{"execution":{"iopub.status.busy":"2024-03-03T17:57:32.711337Z","iopub.execute_input":"2024-03-03T17:57:32.711855Z","iopub.status.idle":"2024-03-03T17:57:33.010571Z","shell.execute_reply.started":"2024-03-03T17:57:32.711807Z","shell.execute_reply":"2024-03-03T17:57:33.009255Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#By Rob Mulla https://www.kaggle.com/code/robikscube/sign-language-recognition-eda-twitch-stream\n\nfig, ax = plt.subplots(figsize=(4, 4))\ntrain_geo_bo[\"speciesId\"].value_counts().head().sort_values(ascending=True).plot(\n    kind=\"barh\", color='r', ax=ax, title=\"European Flora Species by Boreal region\"\n)\nax.set_xlabel(\"Number of Training Examples\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-03-03T17:58:37.613906Z","iopub.execute_input":"2024-03-03T17:58:37.614753Z","iopub.status.idle":"2024-03-03T17:58:37.860432Z","shell.execute_reply.started":"2024-03-03T17:58:37.614709Z","shell.execute_reply":"2024-03-03T17:58:37.859289Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#More 8818.0 SpeciesId","metadata":{}},{"cell_type":"code","source":"eeoe = train_geo_bo[train_geo_bo['speciesId']==8818.0]\neeoe.head()","metadata":{"execution":{"iopub.status.busy":"2024-03-03T18:02:29.007891Z","iopub.execute_input":"2024-03-03T18:02:29.008283Z","iopub.status.idle":"2024-03-03T18:02:29.032330Z","shell.execute_reply.started":"2024-03-03T18:02:29.008254Z","shell.execute_reply":"2024-03-03T18:02:29.031487Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Only Latvia has Boreal species 8818.0?","metadata":{}},{"cell_type":"code","source":"eeoe[\"country\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2024-03-03T18:03:40.478720Z","iopub.execute_input":"2024-03-03T18:03:40.479181Z","iopub.status.idle":"2024-03-03T18:03:40.488435Z","shell.execute_reply.started":"2024-03-03T18:03:40.479148Z","shell.execute_reply":"2024-03-03T18:03:40.487082Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Sample size, check above","metadata":{}},{"cell_type":"code","source":"country_params = dict(column=\"country\", tooltip=True, popup=True, colormap='purple', marker_kwds=dict(radius=3.5, fill=True), style_kwds=dict(stroke=False))\neeoe.sample(300).explore(**country_params)","metadata":{"execution":{"iopub.status.busy":"2024-03-03T18:04:44.645965Z","iopub.execute_input":"2024-03-03T18:04:44.646359Z","iopub.status.idle":"2024-03-03T18:04:44.807173Z","shell.execute_reply.started":"2024-03-03T18:04:44.646331Z","shell.execute_reply":"2024-03-03T18:04:44.806011Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#And The Climate zip (EnviromentalRasters) is STILL uploading on Kaggle! More than 2 hours!!!\n\nBefore, it took Forty minutes to download from Seafile.  I'm done after 3h:35m","metadata":{}},{"cell_type":"markdown","source":"Acknowledgements:\n\nOfir Mazor https://www.kaggle.com/code/ofirmazor/quick-maps-exploration-france\n\nRob Mulla https://www.kaggle.com/code/robikscube/sign-language-recognition-eda-twitch-stream","metadata":{}}]}