{"id":38666399,"url":"https://github.com/tahiri-lab/py_madaclim","last_synced_at":"2026-01-17T09:48:48.198Z","repository":{"id":185978733,"uuid":"586105588","full_name":"tahiri-lab/py_madaclim","owner":"tahiri-lab","description":"A simple Python API to interact with the Madaclim database","archived":false,"fork":false,"pushed_at":"2026-01-15T14:24:04.000Z","size":197725,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-15T18:20:14.186Z","etag":null,"topics":["biogeography","climate-data","data-science","environment","python","raster"],"latest_commit_sha":null,"homepage":"https://tahiri-lab.github.io/py_madaclim/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tahiri-lab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-01-07T00:45:52.000Z","updated_at":"2024-09-24T12:56:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"9c602929-7118-4072-ab79-95a5f6a770cb","html_url":"https://github.com/tahiri-lab/py_madaclim","commit_stats":{"total_commits":470,"total_committers":5,"mean_commits":94.0,"dds":"0.11702127659574468","last_synced_commit":"dffa8db616b84f3af409bb993325a7ef4120f871"},"previous_names":["tahiri-lab/py_madaclim"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tahiri-lab/py_madaclim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tahiri-lab%2Fpy_madaclim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tahiri-lab%2Fpy_madaclim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tahiri-lab%2Fpy_madaclim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tahiri-lab%2Fpy_madaclim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tahiri-lab","download_url":"https://codeload.github.com/tahiri-lab/py_madaclim/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tahiri-lab%2Fpy_madaclim/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28505565,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T06:57:29.758Z","status":"ssl_error","status_checked_at":"2026-01-17T06:56:03.931Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["biogeography","climate-data","data-science","environment","python","raster"],"created_at":"2026-01-17T09:48:46.413Z","updated_at":"2026-01-17T09:48:48.018Z","avatar_url":"https://github.com/tahiri-lab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003epy-madaclim: a simple Python API to interact with the Madaclim database\u003c/h1\u003e\n    \u003c!-- badges should work when repo will go public --\u003e\n    \u003cp align=\"center\"\u003e\n        \u003cimg alt=\"GitHub top language\" src=\"https://img.shields.io/github/languages/top/tahiri-lab/py_madaclim?logoColor=blue\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/contributors/tahiri-lab/py_madaclim?color=orange\u0026logo=github\"\u003e\u003c/img\u003e\n        \u003cimg src=\"https://img.shields.io/github/last-commit/tahiri-lab/py_madaclim?color=purple\u0026logo=github\"\u003e\u003c/img\u003e\n        \u003cimg src=\"https://img.shields.io/website/https/tahiri-lab.github.io/py_madaclim.svg\"\u003e\n    \u003c/p\u003e\n\u003c!-- table of contents --\u003e\n\u003cdetails open\u003e\n    \u003csummary\u003eTable of Contents\u003c/summary\u003e\n        \u003col style\u003e\n            \u003cli\u003e\n                \u003ca href=#package-description\u003ePackage Description\u003c/a\u003e\n            \u003c/li\u003e\n            \u003cli\u003e\u003ca href=#installation\u003eInstallation\u003c/a\u003e\u003c/li\u003e\n                \u003cdetails\u003e\u003csummary\u003eOS-specific steps\u003c/summary\u003e\n                \u003cul\u003e\n                    \u003cli \u003e\u003ca href=#install-linux\u003eLinux/UNIX-based systems\u003c/a\u003e\u003c/li\u003e\n                    \u003cli \u003e\u003ca href=#install-win\u003eWindows 10/11\u003c/a\u003e\u003c/li\u003e\n                    \u003cli\u003e\u003ca href=#install-mac\u003emacOS\u003c/a\u003e\u003c/li\u003e\n                \u003c/ul\u003e\n                \u003c/details\u003e\n            \u003cli\u003e\u003ca href=#workflow\u003eGeneral workflow\u003c/a\u003e\u003c/li\u003e\n            \u003cli\u003e\u003ca href=#example\u003eGetting started (quick example)\u003c/a\u003e\u003c/li\u003e\n            \u003cli\u003e\u003ca href=#refs\u003eReferences\u003c/a\u003e\u003c/li\u003e\n            \u003cli\u003e\u003ca href=#contact\u003eContact us\u003c/a\u003e\u003c/li\u003e\n        \u003c/ol\u003e\n\u003c/details\u003e\n\u003c!-- package description --\u003e\n\u003csection\u003e\n    \u003ch2 id=\"package-description\"\u003epy-madaclim Package Description\u003c/h2\u003e\n        \u003cimg src=\"example/example_coll_plot.png\" alt=\"Example of a MadaclimCollection plot with layer 79\"\u003e\n        \u003cp\u003e\n            \u003ccode\u003epy-madaclim\u003c/code\u003e is a Python 3+ package that allows to interact with the \u003ca href=\"https://madaclim.cirad.fr/\"\u003eMadaclim db\u003c/a\u003e, an open-source climate and environmental database for Madagascar.\n        \u003c/p\u003e\n        \u003cp\u003e\n            Fetch and explore the raster-based data with metadata information support, create new datasets from existent spreadsheets/csv/dataframes from any Coordinate Reference System (CRS) and explore/manipulate your data with visualization and transformation tools.\n        \u003c/p\u003e\n        \u003cp\u003e\n            If you prefer Read-The-Docs style documentation go \u003ca href=\"https://tahiri-lab.github.io/py_madaclim/\"\u003ehere\u003c/a\u003e.\n        \u003c/p\u003e\n        \u003cp\u003e\u003ca href=\"https://tahiri-lab.github.io/py_madaclim/modules.html\"\u003eAPI documentation\u003c/a\u003e is also available.\u003c/p\u003e\n\u003c/section\u003e\n\n\u003c!-- Installation --\u003e\n\u003csection\u003e\n\u003ch2 id=\"installation\"\u003eInstallation\u003c/h2\u003e\n\u003ch3\u003eEnvironment setup and requirements\u003c/h3\u003e\n\u003cp\u003e\n\u003ccode\u003epy-madaclim\u003c/code\u003e is working with Python 3.10 and 3.11. For now, we have provided two ways to setup a working environment for both versions:\u003c/p\u003e\n\u003cul\u003e\n    \u003cli\u003eUsing \u003ccode\u003epip\u003c/code\u003e and \u003ccode\u003evenv\u003c/code\u003e for Python=3.10\u003c/li\u003e\n    \u003cli\u003eUsing \u003ca href=\"https://conda.io\"\u003eConda\u003c/a\u003e for Python=3.11\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003e\nThe requirements for the conda setup can be found in \u003ca href=\"https://github.com/tahiri-lab/coffeaPhyloGeo/blob/main/conda_requirements.txt\"\u003econda_requirements.txt\u003c/a\u003e and for the pip setup in \u003ca href=\"https://github.com/tahiri-lab/coffeaPhyloGeo/blob/main/venv_requirements.txt\"\u003evenv_requirements.txt\u003c/a\u003e. OS-specific installation steps are listed below:\n\u003c/p\u003e\n\n\u003c!--  --\u003e\n\u003ch3 id=\"install-linux\"\u003eDebian/Linux/macOS systems\u003c/h3\u003e\n\u003ch4\u003eSteps for \u003ccode\u003epip\u003c/code\u003e installation (Recommended)\u003c/h4\u003e\n\u003col\u003e\n\u003cli\u003eClone the repo and create a new venv\u003c/li\u003e\n\n```bash\ngit clone https://github.com/tahiri-lab/py_madaclim.git\ncd py_madaclim\npython -m venv ~/.pyenv/py_mada_env    #python=3.10\nsource ~/.pyenv/py_mada_env/bin/activate\n```\n\u003cli\u003eActivate the environment and install the requirements\u003c/li\u003e\n\n```bash\npip install -r venv_requirements.txt    # reqs before py_madaclim\npip install .    # to install py-madaclim\n```\n\u003c/ol\u003e\n\u003ch4\u003eSteps for \u003ccode\u003econda\u003c/code\u003e installation (Slower option)\u003c/h4\u003e\n\u003col start=0\u003e\n\u003cli\u003eFirst follow these \u003ca href=\"https://docs.conda.io/projects/conda/en/latest/user-guide/install/linux.html\"\u003einstructions\u003c/a\u003e to install conda on your machine\u003c/li\u003e\n\u003cli\u003eClone the repo and configure the \u003ccode\u003econda-forge\u003c/code\u003e channel\u003c/li\u003e\n\n```bash\ngit clone https://github.com/tahiri-lab/py_madaclim.git\ncd py_madaclim\n\n# Configure correct channel priority in ~/.condarc\nconda config --add channels conda-forge \u0026\u0026 conda config --append channels plotly\nconda config --show channels\n# channels:\n#   - conda-forge\n#   - defaults\n#   - plotly\n```\n\u003cli\u003eCreate the environment with dependencies (slow step, be patient!)\u003c/li\u003e\n\n```bash\nconda create -n py_mada_env --file conda_requirements.txt\n```\n\n\u003cli\u003eActivate the environment and install \u003ccode\u003epy-madaclim\u003c/code\u003e\u003c/li\u003e\n\n```bash\nconda activate py_mada_env\npip install .    # using pip inside conda env\n```\n\u003c/ol\u003e\n\n\n\u003ch3 id=\"install-win\"\u003eWindows\u003c/h3\u003e\n\u003col\u003e\n\u003cli\u003eClone the repo and create a new venv\u003c/li\u003e\n\n```bash\ngit clone https://github.com/tahiri-lab/py_madaclim.git\ncd py_madaclim\npython -m venv ~/.pyenv/py_mada_env    #python=3.10\nsource ~/.pyenv/py_mada_env/Scripts/activate\n```\n\u003cli\u003eActivate the environment and install the requirements\u003c/li\u003e\n\n```bash\npip install -r venv_requirements.txt    # reqs before py_madaclim\npip install .    # to install py-madaclim\n```\n\u003c/ol\u003e\n\n\u003c/section\u003e\n\n\u003c!-- Example --\u003e\n\u003csection\u003e\n\u003ch2 id=\"example\"\u003eGetting Started: Quick Example\u003c/h2\u003e\n\u003cp\u003eFor a full walkthrough, follow along this \u003ca href=\"https://nbviewer.org/github/tahiri-lab/py_madaclim/blob/main/example/full_walkthrough.ipynb\"\u003enotebook\u003c/a\u003e\u003c/p\u003e\n\u003ch3\u003eMadaclim db metadata with the \u003ccode\u003einfo\u003c/code\u003e module\u003c/h3\u003e\n\u003cp\u003eBasic metada and download rasters from Madaclim server\u003c/p\u003e\n\n```python\n# Get available methods and properties for MadaclimLayers\n\u003e\u003e\u003e from py_madaclim.info import MadaclimLayers\n\u003e\u003e\u003e mada_info = MadaclimLayers()\n\u003e\u003e\u003e print(mada_info)\nMadaclimLayers(\n\tall_layers = DataFrame(79 rows x 6 columns)\n\tcategorical_layers = DataFrame(Layers 75, 76, 77, 78 with a total of 79 categories\n\tpublic methods -\u003e download_data, fetch_specific_layers, get_categorical_combinations\n\t\t\t get_layers_labels, select_geoclim_type_layers\n)\n\n# To access all layers as a dataframe\n\u003e\u003e\u003e mada_info.all_layers\ngeoclim_type  layer_number layer_name                       layer_description  is_categorical    units\n0         clim             1      tmin1   Monthly minimum temperature - January           False  °C x 10\n...\n\n# Built-in method to download the Madaclim raster files\n\u003e\u003e\u003e mada_info.download_data(save_dir=cwd)\n```\n\u003cp\u003eGet detailed labels for each raster layers\u003c/p\u003e\n\n```python\n\u003e\u003e\u003e env_labels = mada_info.get_layers_labels(\n    layers_subset=\"env\", \n    as_descriptive_labels=True\n)\n\u003e\u003e\u003e print(env_labels[0])\n'env_71_alt_Altitude (meters)'\n\n```\n\n\u003c!-- MadaclimRasters quick example --\u003e\n\u003ch3\u003eExplore the rasters and create datasets with the \u003ccode\u003eraster_manipulation\u003c/code\u003e module\u003c/h3\u003e\n\u003ch4\u003e\u003ccode\u003eMadaclimRasters\u003c/code\u003e basic properties and visualization methods\u003c/h4\u003e\n\n```python\n\u003e\u003e\u003e from py_madaclim.raster_manipulation import MadaclimRasters\n\n\u003e\u003e\u003e mada_rasters = MadaclimRasters(\"madaclim_current.tif\", \"madaclim_enviro.tif\")\n\u003e\u003e\u003e print(mada_rasters)\nMadaclimRasters(\n\tclim_raster = madaclim_current.tif,\n\tclim_crs = epsg:32738,\n\tclim_nodata_val = -32768.0\n\tenv_raster = madaclim_enviro.tif,\n\tenv_crs = epsg:32738,\n\tenv_nodata_val = -32768.0\n)\n\n# Basic visualization for a continuous data layer\n\u003e\u003e\u003e mada_rasters.plot_layer(\n...     layer=env_labels[0], \n...     imshow_cmap=\"terrain\", \n...     histplot_binwidth=100, histplot_stat=\"count\", \n... )\n```\n\u003cimg src=\"example/rastplot_1.png\" alt=\"dasdas\" width=500\u003e\n\n\u003ch4\u003eCreate sample points with \u003ccode\u003eMadaclimPoint\u003c/code\u003e and \u003ccode\u003eMadaclimCollection\u003c/code\u003e\u003c/h4\u003e\n\n```python\n\u003e\u003e\u003e from py_madaclim.raster_manipulation import MadaclimPoint\n\n# Single point\n\u003e\u003e\u003e specimen_1 = MadaclimPoint(specimen_id=\"abbayesii\", longitude=46.8624, latitude=-24.7541)\n\n# Multipoints\n\u003e\u003e\u003e coll = MadaclimCollection.populate_from_csv(\"collection_example.csv\")\n\u003e\u003e\u003e print(coll[0])\nMadaclimPoint(\n\tspecimen_id = ABA,\n\tsource_crs = 4326,\n\tlongitude = 46.8624,\n\tlatitude = -24.7541,\n\tmada_geom_point = POINT (688328.2403248843 7260998.022932809),\n\tsampled_layers = None (Not sampled yet),\n\tnodata_layers = None (Not sampled yet),\n\tis_categorical_encoded = False,\n\tSpecies = C.abbayesii,\n\tBotanical_series = Millotii,\n\tGenome_size_2C_pg = 1.25,\n\tgdf.shape = (1, 11)\n)\n```\n\u003ch4\u003eSample the rasters, visualize and encode the data for ML-related tasks\u003c/h4\u003e\n\n```python\n# Sample the collection reflects the changes to the geodataframe\n\u003e\u003e\u003e coll.sample_from_rasters(\n...     clim_raster=mada_rasters.clim_raster,\n...     env_raster=mada_rasters.env_raster,\n...     layers_to_sample=\"all\",   # Or any single/list of layers labels\n...     layer_info=True\n... )\n\u003e\u003e\u003e coll.gdf[\"specimen_id\", env_labels[-1]]\n```\n| specimen_id | Percentage of forest cover in 1 km by 1 km grid cells (%) |\n|-------------|-----------------------------------------------------------|\n| ABA         | 100                                                       |\n| AMB         | 65                                                        |\n| ANK1        | 20                                                        |\n| BISS        | 89                                                        |\n| COS         | 0                                                         |\n| VOHE        | 88                                                        |\n\n\n```python\n# Visualize on the raster map\n\u003e\u003e\u003e coll.plot_on_layer(env_labels[-1], imshow_cmap=\"coolwarm\")\n```\n\u003cimg src=\"example/rastplot_2.png\" alt=\"Collection plot example\" width=500\u003e\n\nBinary encoding for downstream ML applications\n\n```python\n# One Hot encoding updates the object dynamically\n\u003e\u003e\u003e coll.binary_encode_categorical()\n\u003e\u003e\u003e print(coll.is_categorical_encoded)\nTrue\n\u003e\u003e\u003e coll_categ_layers = set([\"_\".join(label.split(\"_\")[:4]) for label in coll.encoded_categ_labels])\n\u003e\u003e\u003e print(f\"Splitted {len(coll_categ_layers)} layers into {len(coll.encoded_categ_labels)} unique categories\")\nSplitted 4 layers into 83 unique categories\n\n# Updated geodataframe attribute\n\u003e\u003e\u003e env_76_encoded = coll.encoded_categ_labels[12:30]\n\u003e\u003e\u003e coll.gdf[[\"specimen_id\"] + env_76_encoded]\n```\n\n| specimen_id | env_76_soi_Soil types_Alluvio-colluvial_Deposited_Soils | env_76_soi_Soil types_Andosols | env_76_soi_Soil types_Bare_Rocks | env_76_soi_Soil types_Fluvio-marine_Deposited_Soils_-_Mangroves | env_76_soi_Soil types_Highly_Rejuvenated,_Penevoluted_Ferralitic_Soils | env_76_soi_Soil types_Humic_Ferralitic_Soils | env_76_soi_Soil types_Humic_Rejuvenated_Ferralitic_Soils | env_76_soi_Soil types_Hydromorphic_Soils | env_76_soi_Soil types_Indurated-Concretion_Ferralitic_Soils | env_76_soi_Soil types_Podzolic_Soils_and_Podzols | env_76_soi_Soil types_Poorly_Evolved_Erosion_Soils,_Lithosols | env_76_soi_Soil types_Raw_Lithic_Mineral_Soils | env_76_soi_Soil types_Red_Ferruginous_Soils | env_76_soi_Soil types_Red_Fersiallitic_Soils | env_76_soi_Soil types_Rejuvenated_Ferralitic_Soils_with_Degrading_Structure | env_76_soi_Soil types_Rejuvenated_Ferralitic_Soils_with_Little_Degrading_Structure | env_76_soi_Soil types_Salty_Deposited_Soils | env_76_soi_Soil types_Skeletal_Shallow_Eroded_Ferruginous_Soils |\n|-------------|------------------------------------------------|-----------------------------|----------------------------|----------------------------------------------------|-----------------------------------------------------------|-------------------------------------|------------------------------------------|------------------------------------|-------------------------------------------------|--------------------------------------------|------------------------------------------------|---------------------------------------|-------------------------------------|-------------------------------------|--------------------------------------------------|------------------------------------------------------|----------------------------------|----------------------------------------|\n| ABA         | 0                                              | 1                           | 0                          | 0                                                  | 0                                                       | 0                                 | 0                                      | 0                                  | 0                                           | 0                                          | 0                                        | 0                                   | 0                                 | 0                                 | 0                                                  | 0                                                      | 0                              | 0                                        |\n| AMB         | 0                                              | 0                           | 0                          | 0                                                  | 0                                                       | 0                                 | 0                                      | 1                                  | 0                                           | 0                                          | 0                                        | 0                                   | 0                                 | 0                                 | 0                                                  | 0                                                      | 0                              | 0                                        |\n| ANK1        | 0                                              | 0                           | 0                          | 0                                                  | 1                                                       | 0                                 | 0                                      | 0                                  | 0                                           | 0                                          | 0                                        | 0                                   | 0                                 | 0                                 | 0                                                  | 0                                                      | 0                              | 0                                        |\n| BISS        | 0                                              | 0                           | 0                          | 0                                                  | 0                                                       | 0                                 | 0                                      | 0                                  | 0                                           | 0                                          | 0                                        | 0                                   | 0                                 | 0                                 | 0                                                  | 0                                                      | 0                              | 1                                        |\n| COS         | 0                                              | 0                           | 0                          | 1                                                  | 0                                                       | 0                                 | 0                                      | 0                                  | 0                                           | 0                                          | 0                                        | 0                                   | 0                                 | 0                                 | 0                                                  | 0                                                      | 0                              | 0                                        |\n| VOHE        | 0                                              | 1                           | 0                          | 0                                                  | 0                                                       | 0                                 | 0                                      | 0                                  | 0                                           | 0                                          | 0                                        | 0                                   | 0                                 | 0                                 | 0                                                  | 0                                                      | 0                              | 0                                        |\n\n\n\u003c!-- GBIF API PORTION --\u003e\n\u003ch3\u003eGBIF API utilities for pre-data fetching in the \u003ccode\u003eutils\u003c/code\u003e module\u003c/h3\u003e\n\u003ch4\u003eRequest an occurence search and download the data\u003c/h4\u003e\n\n```python\n\u003e\u003e\u003e from py_madaclim.utils import gbif_api\n\n# Get taxonKey of interest\n\u003e\u003e\u003e coffea_key = gbif_api.get_taxon_key_by_species_match(\"coffea\")\nEXACT match type found with 95% confidence!\ncanonical name of match: Coffea\nGBIF_taxon_key: 2895315\n\n# Search occurrences\nrecent_years = (2010, 2023)\n\u003e\u003e\u003e coffea_search_results_2010_present = gbif_api.search_occ_mdg_valid_coordinates(\n...     taxon_key=coffea_key,\n...     year_range=recent_years\n... )\nFetching all 613 occurences in year range 2010-2023...\nExtracting occurences 0 to 300...\nExtracting occurences 300 to 600...\nExtracting occurences 600 to 613...\nTotal records retrieved: 613\n\n# ...Or create a download for a given search\n\u003e\u003e\u003e from dotenv import load_dotenv\n\u003e\u003e\u003e import os\n\u003e\u003e\u003e load_dotenv(\".env\")\nTrue\n\u003e\u003e\u003e download_id = gbif_api.request_occ_download_mdg_valid_coordinates(\n...     taxon_key=coffea_key,\n...     email=your_email@gmail.com,\n...     year_range=recent_years    # Defaults to None which is all possible years\n... )\n\n# Download, extract and read as df\n\u003e\u003e\u003e coffea_gbif_df = gbif_api.download_extract_read_occ(\n    download_id=download_id,\n    target_dir=\"gbif_example\"\n)\nResponse OK from https://api.gbif.org/v1/occurrence/download for the given 'download_id'\nProgress for download_0008397-230810091245214.zip : 100.0% completed of 0.21 MB downloaded [ average speed of 0.41 MB/s ]\nExtracting all 17 files to target location: .../download_0008397-230810091245214/\nRead and saved core data into pandas df: occurrence.txt\n```\n\n\u003ch4\u003eCreate a MadaclimCollection from the GBIF occurrences\u003c/h4\u003e\n\n```python\n# Keep relevant data\n\u003e\u003e\u003e df = coffea_gbif_df.loc[coffea_gbif_df[\"taxonRank\"] == \"SPECIES\"]\n\u003e\u003e\u003e df = df.loc[:, [\"verbatimScientificName\", \"decimalLongitude\", \"decimalLatitude\", \"year\"]]\n\u003e\u003e\u003e df = df.reset_index().drop(columns=\"index\")\n\u003e\u003e\u003e df[\"specimen_id\"] = df.apply(lambda row: f\"{row['verbatimScientificName']}_{row.name}\", axis=1)\n\u003e\u003e\u003e df[\"specimen_id\"] = df[\"specimen_id\"].str.strip(\"Coffea \")\n\u003e\u003e\u003e # Format for MadaclimCollection constructor\n\u003e\u003e\u003e df.columns = [\"genus_species\", \"longitude\", \"latitude\", \"year\", \"specimen_id\"]\n\u003e\u003e\u003e df.head()\n```\n| genus_species                    | longitude  | latitude   | year | specimen_id                     |\n|---------------------------------|------------|------------|------|---------------------------------|\n| Coffea perrieri                 | 46.015693  | -17.117573 | 2023 | perrieri_0                      |\n| Coffea pervilleana              | 45.920397  | -17.077081 | 2023 | pervilleana_1                   |\n| Coffea pervilleana              | 45.923007  | -17.078820 | 2023 | pervilleana_2                   |\n| Coffea boiviniana (Baill.) Drake| 49.353747  | -12.336711 | 2020 | boiviniana (Baill.) Drake_3     |\n| Coffea humbertii J.-F.Leroy     | 44.690055  | -22.888583 | 2018 | humbertii J.-F.Leroy_4         |\n\n\n```python\n# Create a collection from recent samples\nrecent_coffea = MadaclimCollection.populate_from_df(df.loc[df[\"year\"] \u003e= 2020])\n```\n\n\u003c/section\u003e\n\n\u003c!-- References --\u003e\n\u003csection\u003e\n    \u003ch2 id=\"refs\"\u003eReferences\u003c/h2\u003e\n        \u003cul\u003e\n            \u003cli\u003e\u003ca href=\"https://tahiri-lab.github.io/py_madaclim/\"\u003epy-madaclim read-the-docs\u003c/a\u003e @ Tahiri-lab\u003c/li\u003e\n            \u003cli\u003e\u003ca href=\"https://madaclim.cirad.fr\"\u003eMadaclim\u003c/a\u003e @ CIRAD\u003c/li\u003e\n            \u003cli\u003e\u003ca href=\"https://tahirinadia.github.io/\"\u003eTahiri lab\u003c/a\u003e @ Université de Sherbrooke\u003c/li\u003e\n        \u003c/ul\u003e\n\u003c/section\u003e\n\n\u003c!-- Contact --\u003e\n\u003csection\u003e\n    \u003ch2 id=\"contact\"\u003eContact Us\u003c/h2\u003e\n        \u003cp\u003eFor any questions, feedback or to get in touch with us : \u003ca href = \"mailto: Nadia.Tahiri@USherbrooke.ca\"\u003eNadia.Tahiri@USherbrooke.ca\u003c/a\u003e\u003c/p\u003e\n        \u003cp\u003eFor our lab's other research projects, visit our \u003ca href=\"https://tahirinadia.github.io/\"\u003ewebsite\u003c/a\u003e\u003c/p\u003e\n\u003c/section\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftahiri-lab%2Fpy_madaclim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftahiri-lab%2Fpy_madaclim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftahiri-lab%2Fpy_madaclim/lists"}