- Proyecto final de Ciencia de Datos para Biodiversidad.
- TEC de Costa Rica
- Alumno: José Renato Morales Mérida.
In [4]:
#cargar librerias
import pandas as pd
import numpy as np
#cargar los datos de iNaturalist
df=pd.read_csv('Observaciones_reptiles.csv')
#obtener las columnas que necesito
df.columns
headers=['id','observed_on','place_guess', 'latitude', 'longitude', 'public_positional_accuracy', 'scientific_name', 'common_name', 'taxon_id']
df2=df[headers]
df2.columns
df2
Out[4]:
id | observed_on | place_guess | latitude | longitude | public_positional_accuracy | scientific_name | common_name | taxon_id | |
---|---|---|---|---|---|---|---|---|---|
0 | 109875 | 1982-08-25 | lake atitlan guatemala | 14.711115 | -91.130668 | NaN | Senticolis triaspis mutabilis | NaN | 28715 |
1 | 109885 | 2002-11-23 | los amates izabal guatemala | 15.317512 | -89.285039 | NaN | Boa imperator | Mazacuata | 539399 |
2 | 172260 | 2007-12-31 | outside Cueva Actun Kan, Santa Elena, Peten, G... | 16.901677 | -89.896016 | 407.0 | Anolis rodriguezii | anolis liso del sureste | 539334 |
3 | 172263 | 2008-01-01 | Zacatan, Las Guacamayas, Hidroelectrica Pasabi... | 15.024366 | -89.692038 | 2016.0 | Sceloporus variabilis | Lagartija espinosa vientre rosado | 36145 |
4 | 226473 | 2013-03-10 | ChiQUIMULLIA, GUATEMALLA. | 14.074310 | -90.373363 | 1822.0 | Sceloporus | Lagartijas espinosas | 36141 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
4814 | 220246607 | 2024-06-02 | Los Amates, Guatemala | 15.268990 | -89.040694 | 8.0 | Ctenosaura similis | Iguana negra de cola espinosa | 35303 |
4815 | 220259986 | 2024-06-02 | 12 Avenida, Guatemala City, Guatemala, GT | 14.603292 | -90.585961 | 170.0 | Scincella | Salamanquesas | 37647 |
4816 | 220276429 | 2024-06-03 | Guatemala | 14.572137 | -90.783269 | 30954.0 | Pituophis lineaticollis | cincuate sureño | 64089 |
4817 | 220323750 | 2024-06-03 | 267Q+GQ2, San Roman, Guatemala | 17.013204 | -89.760796 | 2077.0 | Crocodylus moreletii | Cocodrilo de pantano | 26074 |
4818 | 220475555 | 2024-05-19 | X994+2P7, Macanche, Guatemala | 16.966582 | -89.642896 | 15.0 | Hemidactylus frenatus | Besucona asiática | 51940 |
4819 rows × 9 columns
In [5]:
#Quitar los datos historicos, iNaturalist fue lanzado en 2008 y me interesan los datos desde la aplicación
df3=df2[df['observed_on']>= '2008']
df3
Out[5]:
id | observed_on | place_guess | latitude | longitude | public_positional_accuracy | scientific_name | common_name | taxon_id | |
---|---|---|---|---|---|---|---|---|---|
3 | 172263 | 2008-01-01 | Zacatan, Las Guacamayas, Hidroelectrica Pasabi... | 15.024366 | -89.692038 | 2016.0 | Sceloporus variabilis | Lagartija espinosa vientre rosado | 36145 |
4 | 226473 | 2013-03-10 | ChiQUIMULLIA, GUATEMALLA. | 14.074310 | -90.373363 | 1822.0 | Sceloporus | Lagartijas espinosas | 36141 |
5 | 226476 | 2013-03-11 | Chiquimullia, Guatemalla | 14.084051 | -90.373878 | NaN | Hemidactylus frenatus | Besucona asiática | 51940 |
6 | 226480 | 2013-03-12 | Chiquimullia, Guatemalla | 14.054360 | -90.352005 | NaN | Iguana iguana | Iguana verde | 35342 |
7 | 226489 | 2013-03-13 | Chiquimullia, Guatemalla | 14.083333 | -90.383333 | 1822.0 | Ctenosaura similis | Iguana negra de cola espinosa | 35303 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
4814 | 220246607 | 2024-06-02 | Los Amates, Guatemala | 15.268990 | -89.040694 | 8.0 | Ctenosaura similis | Iguana negra de cola espinosa | 35303 |
4815 | 220259986 | 2024-06-02 | 12 Avenida, Guatemala City, Guatemala, GT | 14.603292 | -90.585961 | 170.0 | Scincella | Salamanquesas | 37647 |
4816 | 220276429 | 2024-06-03 | Guatemala | 14.572137 | -90.783269 | 30954.0 | Pituophis lineaticollis | cincuate sureño | 64089 |
4817 | 220323750 | 2024-06-03 | 267Q+GQ2, San Roman, Guatemala | 17.013204 | -89.760796 | 2077.0 | Crocodylus moreletii | Cocodrilo de pantano | 26074 |
4818 | 220475555 | 2024-05-19 | X994+2P7, Macanche, Guatemala | 16.966582 | -89.642896 | 15.0 | Hemidactylus frenatus | Besucona asiática | 51940 |
4775 rows × 9 columns
In [6]:
#Ahora quiero explorar los datos en el tiempo que me interesan
#Voy a utilizar ydata-profiling
!pip install ydata-profiling
!pip install scikit-learn
Collecting ydata-profiling Downloading ydata_profiling-4.8.3-py2.py3-none-any.whl (359 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 359.5/359.5 kB 2.5 MB/s eta 0:00:00 Requirement already satisfied: scipy<1.14,>=1.4.1 in /usr/local/lib/python3.10/dist-packages (from ydata-profiling) (1.11.4) Requirement already satisfied: pandas!=1.4.0,<3,>1.1 in /usr/local/lib/python3.10/dist-packages (from ydata-profiling) (2.0.3) Requirement already satisfied: matplotlib<3.9,>=3.2 in /usr/local/lib/python3.10/dist-packages (from ydata-profiling) (3.7.1) Requirement already satisfied: pydantic>=2 in /usr/local/lib/python3.10/dist-packages (from ydata-profiling) (2.7.3) Requirement already satisfied: PyYAML<6.1,>=5.0.0 in /usr/local/lib/python3.10/dist-packages (from ydata-profiling) (6.0.1) Requirement already satisfied: jinja2<3.2,>=2.11.1 in /usr/local/lib/python3.10/dist-packages (from ydata-profiling) (3.1.4) Collecting visions[type_image_path]<0.7.7,>=0.7.5 (from ydata-profiling) Downloading visions-0.7.6-py3-none-any.whl (104 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 104.8/104.8 kB 10.7 MB/s eta 0:00:00 Requirement already satisfied: numpy<2,>=1.16.0 in /usr/local/lib/python3.10/dist-packages (from ydata-profiling) (1.25.2) Collecting htmlmin==0.1.12 (from ydata-profiling) Downloading htmlmin-0.1.12.tar.gz (19 kB) Preparing metadata (setup.py) ... done Collecting phik<0.13,>=0.11.1 (from ydata-profiling) Downloading phik-0.12.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (686 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 686.1/686.1 kB 15.5 MB/s eta 0:00:00 Requirement already satisfied: requests<3,>=2.24.0 in /usr/local/lib/python3.10/dist-packages (from ydata-profiling) (2.31.0) Requirement already satisfied: tqdm<5,>=4.48.2 in /usr/local/lib/python3.10/dist-packages (from ydata-profiling) (4.66.4) Requirement already satisfied: seaborn<0.14,>=0.10.1 in /usr/local/lib/python3.10/dist-packages (from ydata-profiling) (0.13.1) Collecting multimethod<2,>=1.4 (from ydata-profiling) Downloading multimethod-1.11.2-py3-none-any.whl (10 kB) Requirement already satisfied: statsmodels<1,>=0.13.2 in /usr/local/lib/python3.10/dist-packages (from ydata-profiling) (0.14.2) Collecting typeguard<5,>=3 (from ydata-profiling) Downloading typeguard-4.3.0-py3-none-any.whl (35 kB) Collecting imagehash==4.3.1 (from ydata-profiling) Downloading ImageHash-4.3.1-py2.py3-none-any.whl (296 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 296.5/296.5 kB 21.7 MB/s eta 0:00:00 Requirement already satisfied: wordcloud>=1.9.1 in /usr/local/lib/python3.10/dist-packages (from ydata-profiling) (1.9.3) Collecting dacite>=1.8 (from ydata-profiling) Downloading dacite-1.8.1-py3-none-any.whl (14 kB) Requirement already satisfied: numba<1,>=0.56.0 in /usr/local/lib/python3.10/dist-packages (from ydata-profiling) (0.58.1) Requirement already satisfied: PyWavelets in /usr/local/lib/python3.10/dist-packages (from imagehash==4.3.1->ydata-profiling) (1.6.0) Requirement already satisfied: pillow in /usr/local/lib/python3.10/dist-packages (from imagehash==4.3.1->ydata-profiling) (9.4.0) Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2<3.2,>=2.11.1->ydata-profiling) (2.1.5) Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib<3.9,>=3.2->ydata-profiling) (1.2.1) Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.10/dist-packages (from matplotlib<3.9,>=3.2->ydata-profiling) (0.12.1) Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib<3.9,>=3.2->ydata-profiling) (4.53.0) Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib<3.9,>=3.2->ydata-profiling) (1.4.5) Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib<3.9,>=3.2->ydata-profiling) (24.0) Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib<3.9,>=3.2->ydata-profiling) (3.1.2) Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.10/dist-packages (from matplotlib<3.9,>=3.2->ydata-profiling) (2.8.2) Requirement already satisfied: llvmlite<0.42,>=0.41.0dev0 in /usr/local/lib/python3.10/dist-packages (from numba<1,>=0.56.0->ydata-profiling) (0.41.1) Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas!=1.4.0,<3,>1.1->ydata-profiling) (2023.4) Requirement already satisfied: tzdata>=2022.1 in /usr/local/lib/python3.10/dist-packages (from pandas!=1.4.0,<3,>1.1->ydata-profiling) (2024.1) Requirement already satisfied: joblib>=0.14.1 in /usr/local/lib/python3.10/dist-packages (from phik<0.13,>=0.11.1->ydata-profiling) (1.4.2) Requirement already satisfied: annotated-types>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from pydantic>=2->ydata-profiling) (0.7.0) Requirement already satisfied: pydantic-core==2.18.4 in /usr/local/lib/python3.10/dist-packages (from pydantic>=2->ydata-profiling) (2.18.4) Requirement already satisfied: typing-extensions>=4.6.1 in /usr/local/lib/python3.10/dist-packages (from pydantic>=2->ydata-profiling) (4.12.1) Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2.24.0->ydata-profiling) (3.3.2) Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2.24.0->ydata-profiling) (3.7) Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2.24.0->ydata-profiling) (2.0.7) Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2.24.0->ydata-profiling) (2024.6.2) Requirement already satisfied: patsy>=0.5.6 in /usr/local/lib/python3.10/dist-packages (from statsmodels<1,>=0.13.2->ydata-profiling) (0.5.6) Requirement already satisfied: attrs>=19.3.0 in /usr/local/lib/python3.10/dist-packages (from visions[type_image_path]<0.7.7,>=0.7.5->ydata-profiling) (23.2.0) Requirement already satisfied: networkx>=2.4 in /usr/local/lib/python3.10/dist-packages (from visions[type_image_path]<0.7.7,>=0.7.5->ydata-profiling) (3.3) Requirement already satisfied: six in /usr/local/lib/python3.10/dist-packages (from patsy>=0.5.6->statsmodels<1,>=0.13.2->ydata-profiling) (1.16.0) Building wheels for collected packages: htmlmin Building wheel for htmlmin (setup.py) ... done Created wheel for htmlmin: filename=htmlmin-0.1.12-py3-none-any.whl size=27080 sha256=f242cd763e29fb5aec7e4c25580359e417be300a1fc2ffa88717474a33418519 Stored in directory: /root/.cache/pip/wheels/dd/91/29/a79cecb328d01739e64017b6fb9a1ab9d8cb1853098ec5966d Successfully built htmlmin Installing collected packages: htmlmin, typeguard, multimethod, dacite, imagehash, visions, phik, ydata-profiling Successfully installed dacite-1.8.1 htmlmin-0.1.12 imagehash-4.3.1 multimethod-1.11.2 phik-0.12.4 typeguard-4.3.0 visions-0.7.6 ydata-profiling-4.8.3 Requirement already satisfied: scikit-learn in /usr/local/lib/python3.10/dist-packages (1.2.2) Requirement already satisfied: numpy>=1.17.3 in /usr/local/lib/python3.10/dist-packages (from scikit-learn) (1.25.2) Requirement already satisfied: scipy>=1.3.2 in /usr/local/lib/python3.10/dist-packages (from scikit-learn) (1.11.4) Requirement already satisfied: joblib>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from scikit-learn) (1.4.2) Requirement already satisfied: threadpoolctl>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from scikit-learn) (3.5.0)
In [7]:
#importamos las librerias
from sklearn import datasets
from ydata_profiling import ProfileReport
In [11]:
#creamos el perfil
perfil= ProfileReport(df3, title='Informe de registros de reptiles iNaturalist', explorative=True )
#mostramos el reporte en un notebook
perfil.to_notebook_iframe()
#crear el html
perfil.to_file("reporte del perfil.html")
Output hidden; open in https://colab.research.google.com to view.
In [8]:
#hago un histograma para observar en que año se ha observado mayor cantidad de reptiles
import matplotlib.pyplot as plt
#que las fechas esten en formato datetime
df3['observed_on']=pd.to_datetime(df3['observed_on'])
#Contar cuantas ocurrencias hay por año
df4=df3.groupby(df3['observed_on'].dt.year).size().reset_index(name='Ocurrencias')
df4
#Generar un gráfico de barras para observar las ocurrencias por año
#tamaño del gráfico
plt.figure(figsize=(10,6))
plt.bar(df4['observed_on'], df4['Ocurrencias'], color= 'skyblue')
#que se muestren todos los años
plt.xticks(df4['observed_on'])
#Título del gráfico
plt.title('Ocurrencias por año de Reptiles en Guatemala por Ciencia Ciudadana')
#etiqueta del eje Y
plt.ylabel('Ocurrencias')
#etiqueta del eje X
plt.xlabel('Año')
plt.show()
<ipython-input-8-c8f6128f4dbf>:6: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy df3['observed_on']=pd.to_datetime(df3['observed_on'])
In [9]:
#Obtener que sitios poseen el mayor avistamiento de Reptiles por ciencia Ciudadana
#cargamos las librerias
!pip install geodatasets
!pip install geopy
import geopandas as gpd
import geodatasets
from geopy.geocoders import Nominatim
from geopy.extra.rate_limiter import RateLimiter
Collecting geodatasets Downloading geodatasets-2023.12.0-py3-none-any.whl (19 kB) Requirement already satisfied: pooch in /usr/local/lib/python3.10/dist-packages (from geodatasets) (1.8.1) Requirement already satisfied: platformdirs>=2.5.0 in /usr/local/lib/python3.10/dist-packages (from pooch->geodatasets) (4.2.2) Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from pooch->geodatasets) (24.0) Requirement already satisfied: requests>=2.19.0 in /usr/local/lib/python3.10/dist-packages (from pooch->geodatasets) (2.31.0) Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests>=2.19.0->pooch->geodatasets) (3.3.2) Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests>=2.19.0->pooch->geodatasets) (3.7) Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests>=2.19.0->pooch->geodatasets) (2.0.7) Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests>=2.19.0->pooch->geodatasets) (2024.6.2) Installing collected packages: geodatasets Successfully installed geodatasets-2023.12.0 Requirement already satisfied: geopy in /usr/local/lib/python3.10/dist-packages (2.3.0) Requirement already satisfied: geographiclib<3,>=1.52 in /usr/local/lib/python3.10/dist-packages (from geopy) (2.0)
In [39]:
#obtener los años de mayor avistamiento
df5=df3[df3['observed_on']>="2021"]
df5.head()
#crear el df como geodataframe
df6=gpd.GeoDataFrame(df5, geometry=gpd.points_from_xy(df5.longitude, df5.latitude))
#observar si hay datos vacios
print(df6[['latitude','longitude']].isnull().sum())
print(df6['geometry'].isnull().sum())
df6.head()
latitude 0 longitude 0 dtype: int64 0
Out[39]:
id | observed_on | place_guess | latitude | longitude | public_positional_accuracy | scientific_name | common_name | taxon_id | geometry | |
---|---|---|---|---|---|---|---|---|---|---|
1164 | 67411816 | 2021-01-01 | Mixco, Guatemala, GT | 14.628070 | -90.639555 | 5.0 | Geophis rhodogaster | culebra minadora guatemalteca | 30025 | POINT (-90.63956 14.62807) |
1165 | 67487855 | 2021-01-02 | Villa Nueva, Guatemala | 14.557899 | -90.576820 | NaN | Rhinoclemmys pulcherrima | Tortuga de monte pintada | 39932 | POINT (-90.57682 14.55790) |
1168 | 67827378 | 2021-01-09 | Ciudad de Guatemala, Guatemala, GT | 14.690238 | -90.490670 | NaN | Hemidactylus frenatus | Besucona asiática | 51940 | POINT (-90.49067 14.69024) |
1169 | 67992336 | 2021-01-09 | Iztapa, Escuintla, GT | 13.929196 | -90.700783 | 91.0 | Ctenosaura similis | Iguana negra de cola espinosa | 35303 | POINT (-90.70078 13.92920) |
1170 | 68091548 | 2021-01-14 | Ciudad de Guatemala, Guatemala, GT | 14.690162 | -90.490372 | NaN | Hemidactylus frenatus | Besucona asiática | 51940 | POINT (-90.49037 14.69016) |
In [29]:
# iniciar Nominatim API
from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="geoPandas")
def get_muni(p):
location = geolocator.geocode(f"{p.y},{p.x}")
if location:
return location.address
else:
return None
df6['Municipio'] = df6['geometry'].map(lambda p: get_muni(p))
df6.head()
/usr/local/lib/python3.10/dist-packages/geopandas/geodataframe.py:1538: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy super().__setitem__(key, value)
Out[29]:
id | observed_on | place_guess | latitude | longitude | public_positional_accuracy | scientific_name | common_name | taxon_id | geometry | location | Municipio | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
3 | 172263 | 2008-01-01 | Zacatan, Las Guacamayas, Hidroelectrica Pasabi... | 15.024366 | -89.692038 | 2016.0 | Sceloporus variabilis | Lagartija espinosa vientre rosado | 36145 | POINT (-89.69204 15.02437) | 15.0243658035, -89.6920378288 | Santa Cruz, Río Hondo, Zacapa, 19005, Guatemala |
4 | 226473 | 2013-03-10 | ChiQUIMULLIA, GUATEMALLA. | 14.074310 | -90.373363 | 1822.0 | Sceloporus | Lagartijas espinosas | 36141 | POINT (-90.37336 14.07431) | 14.0743100434, -90.3733634949 | Chiquimulilla, Santa Rosa, 06008, Guatemala |
5 | 226476 | 2013-03-11 | Chiquimullia, Guatemalla | 14.084051 | -90.373878 | NaN | Hemidactylus frenatus | Besucona asiática | 51940 | POINT (-90.37388 14.08405) | 14.0840505713, -90.373878479 | San Antonio Los Tamarindos, Chiquimulilla, San... |
6 | 226480 | 2013-03-12 | Chiquimullia, Guatemalla | 14.054360 | -90.352005 | NaN | Iguana iguana | Iguana verde | 35342 | POINT (-90.35201 14.05436) | 14.0543601638, -90.3520050987 | Carretera Chiquimulilla - Ciudad Pedro de Alva... |
7 | 226489 | 2013-03-13 | Chiquimullia, Guatemalla | 14.083333 | -90.383333 | 1822.0 | Ctenosaura similis | Iguana negra de cola espinosa | 35303 | POINT (-90.38333 14.08333) | 14.0833333, -90.3833333 | Chiquimulilla, Santa Rosa, 06008, Guatemala |
In [50]:
df6['Municipio']=df6['Municipio'].str.split(',').str[-4]
df6.head()
Out[50]:
id | observed_on | place_guess | latitude | longitude | public_positional_accuracy | scientific_name | common_name | taxon_id | geometry | Municipio | |
---|---|---|---|---|---|---|---|---|---|---|---|
1164 | 67411816 | 2021-01-01 | Mixco, Guatemala, GT | 14.628070 | -90.639555 | 5.0 | Geophis rhodogaster | culebra minadora guatemalteca | 30025 | POINT (-90.63956 14.62807) | San Lucas Sacatepéquez |
1165 | 67487855 | 2021-01-02 | Villa Nueva, Guatemala | 14.557899 | -90.576820 | NaN | Rhinoclemmys pulcherrima | Tortuga de monte pintada | 39932 | POINT (-90.57682 14.55790) | Villa Nueva |
1168 | 67827378 | 2021-01-09 | Ciudad de Guatemala, Guatemala, GT | 14.690238 | -90.490670 | NaN | Hemidactylus frenatus | Besucona asiática | 51940 | POINT (-90.49067 14.69024) | Chinautla |
1169 | 67992336 | 2021-01-09 | Iztapa, Escuintla, GT | 13.929196 | -90.700783 | 91.0 | Ctenosaura similis | Iguana negra de cola espinosa | 35303 | POINT (-90.70078 13.92920) | NaN |
1170 | 68091548 | 2021-01-14 | Ciudad de Guatemala, Guatemala, GT | 14.690162 | -90.490372 | NaN | Hemidactylus frenatus | Besucona asiática | 51940 | POINT (-90.49037 14.69016) | Chinautla |
In [51]:
df7=df6.dropna(subset=['Municipio'])
df7
Out[51]:
id | observed_on | place_guess | latitude | longitude | public_positional_accuracy | scientific_name | common_name | taxon_id | geometry | Municipio | |
---|---|---|---|---|---|---|---|---|---|---|---|
1164 | 67411816 | 2021-01-01 | Mixco, Guatemala, GT | 14.628070 | -90.639555 | 5.0 | Geophis rhodogaster | culebra minadora guatemalteca | 30025 | POINT (-90.63956 14.62807) | San Lucas Sacatepéquez |
1165 | 67487855 | 2021-01-02 | Villa Nueva, Guatemala | 14.557899 | -90.576820 | NaN | Rhinoclemmys pulcherrima | Tortuga de monte pintada | 39932 | POINT (-90.57682 14.55790) | Villa Nueva |
1168 | 67827378 | 2021-01-09 | Ciudad de Guatemala, Guatemala, GT | 14.690238 | -90.490670 | NaN | Hemidactylus frenatus | Besucona asiática | 51940 | POINT (-90.49067 14.69024) | Chinautla |
1170 | 68091548 | 2021-01-14 | Ciudad de Guatemala, Guatemala, GT | 14.690162 | -90.490372 | NaN | Hemidactylus frenatus | Besucona asiática | 51940 | POINT (-90.49037 14.69016) | Chinautla |
1171 | 68138248 | 2021-01-15 | Flores, Guatemala | 16.916006 | -89.852094 | 31.0 | Crocodylus moreletii | Cocodrilo de pantano | 26074 | POINT (-89.85209 16.91601) | Flores |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
4814 | 220246607 | 2024-06-02 | Los Amates, Guatemala | 15.268990 | -89.040694 | 8.0 | Ctenosaura similis | Iguana negra de cola espinosa | 35303 | POINT (-89.04069 15.26899) | Finca Quirigua D.M. |
4815 | 220259986 | 2024-06-02 | 12 Avenida, Guatemala City, Guatemala, GT | 14.603292 | -90.585961 | 170.0 | Scincella | Salamanquesas | 37647 | POINT (-90.58596 14.60329) | Zona 8 |
4816 | 220276429 | 2024-06-03 | Guatemala | 14.572137 | -90.783269 | 30954.0 | Pituophis lineaticollis | cincuate sureño | 64089 | POINT (-90.78327 14.57214) | Antigua Guatemala |
4817 | 220323750 | 2024-06-03 | 267Q+GQ2, San Roman, Guatemala | 17.013204 | -89.760796 | 2077.0 | Crocodylus moreletii | Cocodrilo de pantano | 26074 | POINT (-89.76080 17.01320) | Jobompiche |
4818 | 220475555 | 2024-05-19 | X994+2P7, Macanche, Guatemala | 16.966582 | -89.642896 | 15.0 | Hemidactylus frenatus | Besucona asiática | 51940 | POINT (-89.64290 16.96658) | Macanché |
2467 rows × 11 columns
In [65]:
#hacer mapa
mapa= gpd.read_file('gadm41_GTM_1.shp')
#plotear mapa
lienzo=mapa.plot(
figsize=(10,10),
color='lightgreen',
edgecolor='w',
linewidth= 0.6,
)
#asignar título
title= f'Concentración de Avistamientos de Reptiles en Guatemala por Ciencia Ciudadana (2021-2024)'
lienzo.set_title(title, fontdict={'fontsize': '25', 'fontweight': '3'})
#etiquetas
lienzo.set_ylabel('Latitud')
lienzo.set_xlabel('Longitud')
# Agregar cruz del Norte
north_arrow_x = 0.95
north_arrow_y = 0.95
lienzo.annotate('N', xy=(north_arrow_x, north_arrow_y), xytext=(north_arrow_x, north_arrow_y-0.05),
arrowprops=dict(facecolor='black', shrink=0.05),
ha='center', va='center', fontsize=12, xycoords=lienzo.transAxes)
#generar mapa
df7.plot(ax=lienzo)
Out[65]:
<Axes: title={'center': 'Concentración de Avistamientos de Reptiles en Guatemala por Ciencia Ciudadana (2021-2024)'}, xlabel='Longitud', ylabel='Latitud'>