Curso: Procesamiento de Datos Geoespaciales¶
Proyecto Final¶
Profesor: Manuel Vargas Redbioma
Fecha de entrega: Viernes 14 de marzo de 2025, 11:59 p.m.
Medio de entrega: Por medio de Google Drive-Classroom.
Entregables: Un archivo jupyter ( .IPYNB ).
Estudiantes:
- Rebeca Quesada Céspedes
- Alexander Barrantes Herrera
1. Objetivos¶
Cada estudiante debe mostrar que es capaz de:
- Desarrollar programas en el lenguaje de programación Python orientados al procesamiento de datos geoespaciales de biodiversidad.
- Aplicar un enfoque de ciencia de datos en los procesos de importación, transformación, visualización, análisis y comunicación de datos geoespaciales de biodiversidad.
- Desarrollar soluciones reproducibles a problemas computacionales mediante Python.
- Integrar visualizaciones tabulares, gráficas y geoespaciales de datos de biodiversidad en documentos y aplicaciones interactivas desarrolladas en Python.
2. Entregables¶
Cada estudiante debe mostrar que es capaz de:
- Dirección de un documento en Google Colab con el contenido especificado en la sección Desarrollo.
- Esta tarea puede realizarse individualmente o en parejas. Cada estudiante o equipo de trabajo debe ser capaz de explicar la solución que presenta
3. Desarrollo¶
Distribución de "Ara macao" y su relación con la precipitación#¶
Introducción##¶
El Ara macao o lapa roja (Fig 1) es un ave de la familia de los psitácidos. Se distribuye desde México hasta Bolivia y se ha observado en gran cantidad de lugares de Costa Rica. En algunas partes, se encuentra amenazada de acuerdo con la lista roja de la UICN. Se alimenta principalmente de hojas, flores, semillas e insectos. Puede llegar a medir hasta 90 cm de longitud y 1 kg de peso y se distribuye desde México hasta Bolivia y es el ave nacional de Honduras. Suplumaje colorido lo hace muy llamativo. Es un ave de hábitos diurnos y son muy sociables, se comunican por vocalización principalmente y llegan a formar bandadas de decenas de miembros.
Figura 1. Ara macao
Objetivo#¶
El objetivo de este trabajo fue describir la distribución de la lapa roja a nivel mundial.
Metodología##¶
Se obtuvieron datos de fuentes como GBIF para conocer los puntos de avistamiento de la lapa roja para el país. De esta consulta se generó un enlace donde se pueden descargar los datos existentes en la plataforma hasta el 14 de marzo de 2025.
A partir de datos de la base de datos de Giovanni (Beaudoing & Rodell, 2020) que genera datos provenientes de sensores remotos, se generó una imagen con el promedio anual de precipitación para el año 2024. La base de datos generó un archivo en formato NetCDF con el que se utilizó para el análisis.
Resultados##¶
Utilizando un cuaderno de notas de Jupyter, se elaboró una imagen para describir la distribución de la Lapa Roja (Ara Macao) en Costa Rica.
0. Carga de Librerías y DataSet¶
# Importar geopandas y geodatasets
!pip install geodatasets
!pip install ydata-profiling
# Biblioteca requerida para mapas interactivos
!pip install mapclassify --quiet
# Instalación de rasterio
!pip install rasterio --quiet
import geopandas as gpd
import geodatasets
import numpy as np
import pandas as pd
import folium
import plotly.express as px
from matplotlib import pyplot as plt
from ydata_profiling import ProfileReport
import mapclassify
import rasterio
import rasterio.plot
Requirement already satisfied: geodatasets in /usr/local/lib/python3.11/dist-packages (2024.8.0) Requirement already satisfied: pooch in /usr/local/lib/python3.11/dist-packages (from geodatasets) (1.8.2) Requirement already satisfied: platformdirs>=2.5.0 in /usr/local/lib/python3.11/dist-packages (from pooch->geodatasets) (4.3.6) Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.11/dist-packages (from pooch->geodatasets) (24.2) Requirement already satisfied: requests>=2.19.0 in /usr/local/lib/python3.11/dist-packages (from pooch->geodatasets) (2.32.3) Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.11/dist-packages (from requests>=2.19.0->pooch->geodatasets) (3.4.1) Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.11/dist-packages (from requests>=2.19.0->pooch->geodatasets) (3.10) Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.11/dist-packages (from requests>=2.19.0->pooch->geodatasets) (2.3.0) Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.11/dist-packages (from requests>=2.19.0->pooch->geodatasets) (2025.1.31) Requirement already satisfied: ydata-profiling in /usr/local/lib/python3.11/dist-packages (4.14.0) Requirement already satisfied: scipy<1.16,>=1.4.1 in /usr/local/lib/python3.11/dist-packages (from ydata-profiling) (1.14.1) Requirement already satisfied: pandas!=1.4.0,<3.0,>1.1 in /usr/local/lib/python3.11/dist-packages (from ydata-profiling) (2.2.2) Requirement already satisfied: matplotlib<=3.10,>=3.5 in /usr/local/lib/python3.11/dist-packages (from ydata-profiling) (3.10.0) Requirement already satisfied: pydantic>=2 in /usr/local/lib/python3.11/dist-packages (from ydata-profiling) (2.10.6) Requirement already satisfied: PyYAML<6.1,>=5.0.0 in /usr/local/lib/python3.11/dist-packages (from ydata-profiling) (6.0.2) Requirement already satisfied: jinja2<3.2,>=2.11.1 in /usr/local/lib/python3.11/dist-packages (from ydata-profiling) (3.1.6) Requirement already satisfied: visions<0.8.2,>=0.7.5 in /usr/local/lib/python3.11/dist-packages (from visions[type_image_path]<0.8.2,>=0.7.5->ydata-profiling) (0.8.1) Requirement already satisfied: numpy<2.2,>=1.16.0 in /usr/local/lib/python3.11/dist-packages (from ydata-profiling) (1.26.4) Requirement already satisfied: htmlmin==0.1.12 in /usr/local/lib/python3.11/dist-packages (from ydata-profiling) (0.1.12) Requirement already satisfied: phik<0.13,>=0.11.1 in /usr/local/lib/python3.11/dist-packages (from ydata-profiling) (0.12.4) Requirement already satisfied: requests<3,>=2.24.0 in /usr/local/lib/python3.11/dist-packages (from ydata-profiling) (2.32.3) Requirement already satisfied: tqdm<5,>=4.48.2 in /usr/local/lib/python3.11/dist-packages (from ydata-profiling) (4.67.1) Requirement already satisfied: seaborn<0.14,>=0.10.1 in /usr/local/lib/python3.11/dist-packages (from ydata-profiling) (0.13.2) Requirement already satisfied: multimethod<2,>=1.4 in /usr/local/lib/python3.11/dist-packages (from ydata-profiling) (1.12) Requirement already satisfied: statsmodels<1,>=0.13.2 in /usr/local/lib/python3.11/dist-packages (from ydata-profiling) (0.14.4) Requirement already satisfied: typeguard<5,>=3 in /usr/local/lib/python3.11/dist-packages (from ydata-profiling) (4.4.2) Requirement already satisfied: imagehash==4.3.1 in /usr/local/lib/python3.11/dist-packages (from ydata-profiling) (4.3.1) Requirement already satisfied: wordcloud>=1.9.3 in /usr/local/lib/python3.11/dist-packages (from ydata-profiling) (1.9.4) Requirement already satisfied: dacite>=1.8 in /usr/local/lib/python3.11/dist-packages (from ydata-profiling) (1.9.2) Requirement already satisfied: numba<1,>=0.56.0 in /usr/local/lib/python3.11/dist-packages (from ydata-profiling) (0.60.0) Requirement already satisfied: PyWavelets in /usr/local/lib/python3.11/dist-packages (from imagehash==4.3.1->ydata-profiling) (1.8.0) Requirement already satisfied: pillow in /usr/local/lib/python3.11/dist-packages (from imagehash==4.3.1->ydata-profiling) (11.1.0) Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.11/dist-packages (from jinja2<3.2,>=2.11.1->ydata-profiling) (3.0.2) Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.11/dist-packages (from matplotlib<=3.10,>=3.5->ydata-profiling) (1.3.1) Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.11/dist-packages (from matplotlib<=3.10,>=3.5->ydata-profiling) (0.12.1) Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.11/dist-packages (from matplotlib<=3.10,>=3.5->ydata-profiling) (4.56.0) Requirement already satisfied: kiwisolver>=1.3.1 in /usr/local/lib/python3.11/dist-packages (from matplotlib<=3.10,>=3.5->ydata-profiling) (1.4.8) Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.11/dist-packages (from matplotlib<=3.10,>=3.5->ydata-profiling) (24.2) Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.11/dist-packages (from matplotlib<=3.10,>=3.5->ydata-profiling) (3.2.1) Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.11/dist-packages (from matplotlib<=3.10,>=3.5->ydata-profiling) (2.8.2) Requirement already satisfied: llvmlite<0.44,>=0.43.0dev0 in /usr/local/lib/python3.11/dist-packages (from numba<1,>=0.56.0->ydata-profiling) (0.43.0) Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.11/dist-packages (from pandas!=1.4.0,<3.0,>1.1->ydata-profiling) (2025.1) Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.11/dist-packages (from pandas!=1.4.0,<3.0,>1.1->ydata-profiling) (2025.1) Requirement already satisfied: joblib>=0.14.1 in /usr/local/lib/python3.11/dist-packages (from phik<0.13,>=0.11.1->ydata-profiling) (1.4.2) Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.11/dist-packages (from pydantic>=2->ydata-profiling) (0.7.0) Requirement already satisfied: pydantic-core==2.27.2 in /usr/local/lib/python3.11/dist-packages (from pydantic>=2->ydata-profiling) (2.27.2) Requirement already satisfied: typing-extensions>=4.12.2 in /usr/local/lib/python3.11/dist-packages (from pydantic>=2->ydata-profiling) (4.12.2) Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.11/dist-packages (from requests<3,>=2.24.0->ydata-profiling) (3.4.1) Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.11/dist-packages (from requests<3,>=2.24.0->ydata-profiling) (3.10) Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.11/dist-packages (from requests<3,>=2.24.0->ydata-profiling) (2.3.0) Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.11/dist-packages (from requests<3,>=2.24.0->ydata-profiling) (2025.1.31) Requirement already satisfied: patsy>=0.5.6 in /usr/local/lib/python3.11/dist-packages (from statsmodels<1,>=0.13.2->ydata-profiling) (1.0.1) Requirement already satisfied: attrs>=19.3.0 in /usr/local/lib/python3.11/dist-packages (from visions<0.8.2,>=0.7.5->visions[type_image_path]<0.8.2,>=0.7.5->ydata-profiling) (25.2.0) Requirement already satisfied: networkx>=2.4 in /usr/local/lib/python3.11/dist-packages (from visions<0.8.2,>=0.7.5->visions[type_image_path]<0.8.2,>=0.7.5->ydata-profiling) (3.4.2) Requirement already satisfied: puremagic in /usr/local/lib/python3.11/dist-packages (from visions<0.8.2,>=0.7.5->visions[type_image_path]<0.8.2,>=0.7.5->ydata-profiling) (1.28) Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.11/dist-packages (from python-dateutil>=2.7->matplotlib<=3.10,>=3.5->ydata-profiling) (1.17.0)
#Conecta a la carpeta Google Drive y carga la carpeta de archivo Shape file"
from google.colab import drive
drive.mount('/content/drive')
Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount("/content/drive", force_remount=True).
# Carga el Shape de Registros de Ave "Ara macao"
macao = gpd.read_file("/content/drive/MyDrive/CURSO_PYTHON/Python_Procesamiento_Datos_Geoespaciales/Proyecto_Final/ave_ara_macao_20250313_convertido.xlsx")
# Crear un GeoDataFrame a partir del DataFrame
macao = gpd.GeoDataFrame(
macao,
geometry=gpd.points_from_xy(macao.decimalLongitude, macao.decimalLatitude),
crs='EPSG:4326'
)
# Mostrar los primeros registros del GeoDataFrame,
# incluyendo la columna de geometría
macao[['gbifID', 'countryCode', 'decimalLatitude','decimalLongitude', 'geometry']].head()
/usr/local/lib/python3.11/dist-packages/geopandas/geoseries.py:860: UserWarning: GeoSeries.notna() previously returned False for both missing (None) and empty geometries. Now, it only returns False for missing values. Since the calling GeoSeries contains empty geometries, the result has changed compared to previous versions of GeoPandas. Given a GeoSeries 's', you can use '~s.is_empty & s.notna()' to get back the old behaviour. To further ignore this warning, you can do: import warnings; warnings.filterwarnings('ignore', 'GeoSeries.notna', UserWarning) return self.notna()
gbifID | countryCode | decimalLatitude | decimalLongitude | geometry | |
---|---|---|---|---|---|
0 | 4565571313 | GF | 4.04298 | -54.03516 | POINT (-54.03516 4.04298) |
1 | 2249766919 | None | NaN | NaN | POINT EMPTY |
2 | 2251355829 | JP | 35.02600 | 135.78100 | POINT (135.781 35.026) |
3 | 2248813900 | None | NaN | NaN | POINT EMPTY |
4 | 2251356880 | JP | 34.49700 | 132.44200 | POINT (132.442 34.497) |
# Muestra las primeras filas de Aves "Ara macao" según la ubicación donde se localizó
macao
gbifID | datasetKey | occurrenceID | kingdom | phylum | class | order | family | genus | species | ... | dateIdentified | license | rightsHolder | recordedBy | typeStatus | establishmentMeans | lastInterpreted | mediaType | issue | geometry | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 4565571313 | e4610af0-d61d-4fce-853f-2894f53cd346 | f24030d5-6f57-4752-8b62-209bb91ec0b9 | Animalia | Chordata | Aves | Psittaciformes | Psittacidae | Ara | Ara macao | ... | None | CC_BY_4_0 | None | PELLETIER Vincent | None | None | 2025-02-01T01:45:20.431Z | None | COUNTRY_MISMATCH | POINT (-54.03516 4.04298) |
1 | 2249766919 | 040c5662-da76-4782-a48e-cdea1892d14c | GBIR10955-19 | Animalia | Chordata | Aves | Psittaciformes | Psittacidae | Ara | Ara macao | ... | None | CC_BY_4_0 | None | None | None | None | 2025-02-25T04:37:41.356Z | None | TAXON_MATCH_TAXON_CONCEPT_ID_IGNORED | POINT EMPTY |
2 | 2251355829 | 040c5662-da76-4782-a48e-cdea1892d14c | SIARA011-10 | Animalia | Chordata | Aves | Psittaciformes | Psittacidae | Ara | Ara macao | ... | None | CC_BY_4_0 | None | Wildlife Research Center of Kyoto University | None | None | 2025-02-25T04:36:37.457Z | None | COUNTRY_DERIVED_FROM_COORDINATES | POINT (135.781 35.026) |
3 | 2248813900 | 040c5662-da76-4782-a48e-cdea1892d14c | BROMB220-06 | Animalia | Chordata | Aves | Psittaciformes | Psittacidae | Ara | Ara macao | ... | None | CC_BY_4_0 | None | None | None | None | 2025-02-25T04:33:38.762Z | None | TAXON_MATCH_TAXON_CONCEPT_ID_IGNORED | POINT EMPTY |
4 | 2251356880 | 040c5662-da76-4782-a48e-cdea1892d14c | SIARA009-10 | Animalia | Chordata | Aves | Psittaciformes | Psittacidae | Ara | Ara macao | ... | None | CC_BY_4_0 | None | Shinji Minami | None | None | 2025-02-25T04:36:37.483Z | None | COUNTRY_DERIVED_FROM_COORDINATES | POINT (132.442 34.497) |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
121471 | 5004142436 | edebebc8-bfa9-4341-91fd-c2c1455353e4 | Frontera:Cachicamo:Fauna:413 | Animalia | Chordata | Aves | Psittaciformes | Psittacidae | Ara | Ara macao | ... | None | CC_BY_NC_4_0 | None | Cándida Caicedo | None | None | 2025-02-01T02:01:23.300Z | None | COORDINATE_ROUNDED | POINT (-71.69786 4.84405) |
121472 | 2473958057 | 5818223b-9b8e-432c-9fca-cb4c43387e6a | 82e3ca7a-75a3-24f6-e053-2614a8c008ee | Animalia | Chordata | Aves | Psittaciformes | Psittacidae | Ara | Ara macao | ... | None | CC_BY_4_0 | None | Alexandre Renaudier Sylvain Uriot Tanguy Devil... | None | None | 2025-01-31T20:49:37.019Z | None | COUNTRY_MISMATCH | POINT (-53.86855 3.65) |
121473 | 4439058397 | 4d0d62d2-c622-4ae8-bcd8-22d3b4953ed3 | EPM:Fauna-ValleAburra:208 | Animalia | Chordata | Aves | Psittaciformes | Psittacidae | Ara | Ara macao | ... | None | CC_BY_NC_4_0 | None | None | None | None | 2025-01-31T20:22:58.583Z | None | None | POINT (-75.57088 6.19714) |
121474 | 4439059127 | 4d0d62d2-c622-4ae8-bcd8-22d3b4953ed3 | EPM:Fauna-ValleAburra:319 | Animalia | Chordata | Aves | Psittaciformes | Psittacidae | Ara | Ara macao | ... | None | CC_BY_NC_4_0 | None | None | None | None | 2025-01-31T20:22:58.742Z | None | None | POINT (-75.57853 6.20016) |
121475 | 3343398504 | dac0a667-6beb-4c18-a456-e2a5bb43757d | 36623 | Animalia | Chordata | Aves | Psittaciformes | Psittacidae | Ara | Ara macao | ... | None | CC_BY_NC_4_0 | Leeds Museums and Galleries | None | None | None | 2025-03-11T22:48:10.996Z | None | COLLECTION_MATCH_NONE | POINT EMPTY |
121476 rows × 51 columns
# Mostrar toda la informacion del dataframe
macao.info()
<class 'geopandas.geodataframe.GeoDataFrame'> RangeIndex: 121476 entries, 0 to 121475 Data columns (total 51 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 gbifID 121476 non-null int64 1 datasetKey 121476 non-null object 2 occurrenceID 121145 non-null object 3 kingdom 121476 non-null object 4 phylum 121476 non-null object 5 class 121476 non-null object 6 order 121476 non-null object 7 family 121476 non-null object 8 genus 121476 non-null object 9 species 121476 non-null object 10 infraspecificEpithet 171 non-null object 11 taxonRank 121476 non-null object 12 scientificName 121476 non-null object 13 verbatimScientificName 121472 non-null object 14 verbatimScientificNameAuthorship 909 non-null object 15 countryCode 121228 non-null object 16 locality 116349 non-null object 17 stateProvince 119528 non-null object 18 occurrenceStatus 121385 non-null object 19 individualCount 105010 non-null float64 20 publishingOrgKey 121385 non-null object 21 decimalLatitude 120401 non-null float64 22 decimalLongitude 120401 non-null float64 23 coordinateUncertaintyInMeters 6681 non-null float64 24 coordinatePrecision 16 non-null float64 25 elevation 776 non-null float64 26 elevationAccuracy 724 non-null float64 27 depth 527 non-null float64 28 depthAccuracy 527 non-null float64 29 eventDate 121097 non-null object 30 day 120926 non-null float64 31 month 120980 non-null float64 32 year 121084 non-null float64 33 taxonKey 121385 non-null float64 34 speciesKey 121385 non-null float64 35 basisOfRecord 121385 non-null object 36 institutionCode 119131 non-null object 37 collectionCode 118335 non-null object 38 catalogNumber 118370 non-null object 39 recordNumber 174 non-null object 40 identifiedBy 5069 non-null object 41 dateIdentified 4427 non-null object 42 license 121327 non-null object 43 rightsHolder 7453 non-null object 44 recordedBy 120325 non-null object 45 typeStatus 492 non-null object 46 establishmentMeans 151 non-null object 47 lastInterpreted 121222 non-null object 48 mediaType 4743 non-null object 49 issue 117415 non-null object 50 geometry 121476 non-null geometry dtypes: float64(14), geometry(1), int64(1), object(35) memory usage: 47.3+ MB
# Ver todas las columnas del Dataframe
macao.columns
Index(['gbifID', 'datasetKey', 'occurrenceID', 'kingdom', 'phylum', 'class', 'order', 'family', 'genus', 'species', 'infraspecificEpithet', 'taxonRank', 'scientificName', 'verbatimScientificName', 'verbatimScientificNameAuthorship', 'countryCode', 'locality', 'stateProvince', 'occurrenceStatus', 'individualCount', 'publishingOrgKey', 'decimalLatitude', 'decimalLongitude', 'coordinateUncertaintyInMeters', 'coordinatePrecision', 'elevation', 'elevationAccuracy', 'depth', 'depthAccuracy', 'eventDate', 'day', 'month', 'year', 'taxonKey', 'speciesKey', 'basisOfRecord', 'institutionCode', 'collectionCode', 'catalogNumber', 'recordNumber', 'identifiedBy', 'dateIdentified', 'license', 'rightsHolder', 'recordedBy', 'typeStatus', 'establishmentMeans', 'lastInterpreted', 'mediaType', 'issue', 'geometry'], dtype='object')
# Selecciona los campos de Información requeridos
headers = [
'gbifID', 'countryCode', 'decimalLatitude','decimalLongitude','geometry'
]
macao_acortado = macao[headers]
macao_acortado
gbifID | countryCode | decimalLatitude | decimalLongitude | geometry | |
---|---|---|---|---|---|
0 | 4565571313 | GF | 4.042980 | -54.035160 | POINT (-54.03516 4.04298) |
1 | 2249766919 | None | NaN | NaN | POINT EMPTY |
2 | 2251355829 | JP | 35.026000 | 135.781000 | POINT (135.781 35.026) |
3 | 2248813900 | None | NaN | NaN | POINT EMPTY |
4 | 2251356880 | JP | 34.497000 | 132.442000 | POINT (132.442 34.497) |
... | ... | ... | ... | ... | ... |
121471 | 5004142436 | CO | 4.844047 | -71.697863 | POINT (-71.69786 4.84405) |
121472 | 2473958057 | GF | 3.650000 | -53.868550 | POINT (-53.86855 3.65) |
121473 | 4439058397 | CO | 6.197140 | -75.570877 | POINT (-75.57088 6.19714) |
121474 | 4439059127 | CO | 6.200164 | -75.578531 | POINT (-75.57853 6.20016) |
121475 | 3343398504 | None | NaN | NaN | POINT EMPTY |
121476 rows × 5 columns
# Encontrar datos nulos
macao_acortado = macao_acortado.dropna()
macao_acortado
gbifID | countryCode | decimalLatitude | decimalLongitude | geometry | |
---|---|---|---|---|---|
0 | 4565571313 | GF | 4.042980 | -54.035160 | POINT (-54.03516 4.04298) |
2 | 2251355829 | JP | 35.026000 | 135.781000 | POINT (135.781 35.026) |
4 | 2251356880 | JP | 34.497000 | 132.442000 | POINT (132.442 34.497) |
5 | 4916432030 | CO | 6.223055 | -75.580000 | POINT (-75.58 6.22306) |
6 | 2251357906 | JP | 34.654000 | 135.223000 | POINT (135.223 34.654) |
... | ... | ... | ... | ... | ... |
121469 | 4958338405 | CR | 10.699970 | -85.176346 | POINT (-85.17635 10.69997) |
121471 | 5004142436 | CO | 4.844047 | -71.697863 | POINT (-71.69786 4.84405) |
121472 | 2473958057 | GF | 3.650000 | -53.868550 | POINT (-53.86855 3.65) |
121473 | 4439058397 | CO | 6.197140 | -75.570877 | POINT (-75.57088 6.19714) |
121474 | 4439059127 | CO | 6.200164 | -75.578531 | POINT (-75.57853 6.20016) |
120400 rows × 5 columns
1. Generación de Gráficos Estadísticos¶
# Cantidad Total de Países que registran datos de Ave Ara macao en Mundo según GBIF
len(macao_acortado['countryCode'].unique())
44
# Tabla de Registros por País
conteo_pais = macao_acortado["countryCode"].value_counts()
conteo_pais
count | |
---|---|
countryCode | |
CR | 80161 |
PE | 11623 |
CO | 9138 |
BR | 8403 |
EC | 4562 |
VE | 1788 |
GY | 1707 |
GF | 677 |
PA | 593 |
MX | 500 |
SR | 425 |
BO | 367 |
HN | 179 |
NL | 66 |
US | 53 |
GT | 51 |
BZ | 31 |
NI | 13 |
BE | 9 |
JP | 8 |
SV | 6 |
PR | 5 |
FR | 4 |
GP | 3 |
TT | 3 |
AG | 3 |
DE | 2 |
AU | 2 |
MY | 2 |
PT | 2 |
KY | 1 |
BL | 1 |
MV | 1 |
ES | 1 |
MT | 1 |
HK | 1 |
NZ | 1 |
DO | 1 |
SX | 1 |
TW | 1 |
AR | 1 |
ZZ | 1 |
CA | 1 |
BG | 1 |
El país que mostró la mayor cantidad de registros fue Costa Rica con más de 80 mil registros, seguido por Perú, Colombia, Brasil, ecuador y Venezuela (Fig 2).
# Gráfica de Cantidad de Registros por País
# 1. Contar registros por país
registros_x_pais = macao_acortado['countryCode'].value_counts()
# 2. Generar un gráfico de barras
plt.figure(figsize=(20, 6)) # tamaño del gráfico
registros_x_pais.plot(kind='bar')
# 3. Especificar el título y las etiquetas del gráfico
plt.title('Cantidad de Registros por País')
plt.xlabel('País')
plt.ylabel('Cantidad de Registros')
# 4. Mostrar el gráfico
plt.show()
Figura 2. Gráfico de barras registros de Ara macao por país
Los registros de la especie obtenidos de la base de datos GBIF, indican su presencia en 44 países a nivel mundial. De los reportes, el 66,6 % de los datos se registraron para Costa Rica, seguido de 9,7% para Perú (Fig 3).
# Gráfica de % de Registros por País
# Calcula la cantidad por país
paises = macao_acortado['countryCode']
pais_cont = paises.value_counts()
# Agregar % de valor
plt.pie(pais_cont, labels=pais_cont.index, autopct="%0.1f %%")
plt.axis("equal")
# Especificar el título y las etiquetas del gráfico
plt.title('% de Cantidad de Registros por País')
plt.show()
Figura 3. Gráfico de pie de registros de Ara macao por país
2. Generar Mapas - Capa Vectorial¶
# Data Set Ave Ara Macao solo puntos de Geolocalización
headers = [
'decimalLatitude','decimalLongitude','geometry'
]
macao_acortado_geo = macao_acortado[headers]
macao_acortado_geo
decimalLatitude | decimalLongitude | geometry | |
---|---|---|---|
0 | 4.042980 | -54.035160 | POINT (-54.03516 4.04298) |
2 | 35.026000 | 135.781000 | POINT (135.781 35.026) |
4 | 34.497000 | 132.442000 | POINT (132.442 34.497) |
5 | 6.223055 | -75.580000 | POINT (-75.58 6.22306) |
6 | 34.654000 | 135.223000 | POINT (135.223 34.654) |
... | ... | ... | ... |
121469 | 10.699970 | -85.176346 | POINT (-85.17635 10.69997) |
121471 | 4.844047 | -71.697863 | POINT (-71.69786 4.84405) |
121472 | 3.650000 | -53.868550 | POINT (-53.86855 3.65) |
121473 | 6.197140 | -75.570877 | POINT (-75.57088 6.19714) |
121474 | 6.200164 | -75.578531 | POINT (-75.57853 6.20016) |
120400 rows × 3 columns
Los puntos de distribución para Ara macao de la base de datos de GBIF muestran los puntos en varios continentes, no solo para el continente americano (Figura 4).
# Mapa estático de de la ubicación de cada ave "Ara macao"
macao_acortado_geo.plot(figsize = (8,8), edgecolor="w", linewidth=0.3)
<Axes: >
Figura 4. Distribución de puntos de observación de Ara macao
# Crear un geodataframe con datos y polígonos de paises
paises_gdf = gpd.read_file(
'https://raw.githubusercontent.com/datos-geoespaciales-biodiversidad/python/refs/heads/main/datos/otros/naturalearth/paises.gpkg'
)
# Mostrar los primeros registros del GeoDataFrame,
# incluyendo la columna de geometría
paises_gdf[['ADM0_ISO', 'NAME', 'POP_EST', 'GDP_MD', 'geometry']].head()
ADM0_ISO | NAME | POP_EST | GDP_MD | geometry | |
---|---|---|---|---|---|
0 | FJI | Fiji | 889953.0 | 5496 | MULTIPOLYGON (((180 -16.06713, 180 -16.55522, ... |
1 | TZA | Tanzania | 58005463.0 | 63177 | MULTIPOLYGON (((33.90371 -0.95, 34.07262 -1.05... |
2 | B28 | W. Sahara | 603253.0 | 907 | MULTIPOLYGON (((-8.66559 27.65643, -8.66512 27... |
3 | CAN | Canada | 37589262.0 | 1736425 | MULTIPOLYGON (((-122.84 49, -122.97421 49.0025... |
4 | USA | United States of America | 328239523.0 | 21433226 | MULTIPOLYGON (((-122.84 49, -120 49, -117.0312... |
Se muestra un mapa de países a nivel mundial (Fig 5).
# Mapa estático de países
paises_gdf.plot(figsize = (8,8), edgecolor="w", linewidth=0.3)
<Axes: >
Figura 5. Mapa de países
Se generó un mapa que muestra los registro de lapa roja por país (Fig 6).
# Crear figura y ejes para unificar mapas
fig, ax = plt.subplots(figsize=(10, 20))
# Capa de registros según la ubicación del País
paises_gdf.plot(
ax=ax,
color="gray",
edgecolor="w"
)
# Capa de registros de ubicación del ave "Ara macao"
macao_acortado_geo.plot(
ax=ax,
marker="o",
color="red",
markersize=5
)
<Axes: >
Figura 6. Registros de ara macao por país.
Se elaboró un mapa para visualizar los registros de lapa roja para Costa Rica (Fig 7).
# Mapa interactivo de registros de Ara Macao en Costa Rica
macao_acortado_geo[(macao_acortado_geo['decimalLongitude'] < -81) & (macao_acortado_geo['decimalLatitude'] < 12)].explore()