Skip to content

In this project you will find the code to create a Python API using Flask. The goal, to create an API that serves as data of species in Spain, where to find them, when to find them and create a model to predict where we can find species that are not in our database.

Notifications You must be signed in to change notification settings

AnaAGG/APISPECIES2

Repository files navigation

-To-see-species-SpeciesAPI

portada

Repository structure

1- Extract the data information from the GBIF 's API
2 - Create the collection in MongoDB Compass
3 - Create de API
4 - Perform a CLustering Anlysis 5 - Plot some results

API folder : contains the main file of the API and all the files necessary for its operation
Notebooks folder: data access script for the API, connection with Mongo, creation of maps and figures, clustering model
Output folder: contains all the data files that have been generated throughout the project
Images folders: contains some descriptive figures of the API content

Collection data

To store all the date we used a MongaDBCompass. The database is made up of one collection that will receive or give the information through the API. Next I show a table of the information contained in the database and how the codes that you will receive when you make the requests

API information Name in request
Latitude Lat
Longitude Long
Vernacule name common_name
Latin name species
Kingdom kingdom
Class class
Family family
Genus genus
Locality location
Province province
Autonomous Community community

API description

This project is part of the final project of the Ironhack Data Analytics Bootcamp. The main objective of this API is to improve accessibility to the data and information that are usually found dispersed, in different formats and with difficult access. The data of the different domains of knowledge that refer to biodiversity (taxonomy, phylogenetics, morphology, ecology) have been scattered in various formats, in natural history collections and in observational reports field, as well as in the scientific literature and in various reports from those who manage aspects related to biodiversity, that is, the called gray literature. The main objective of this project is support efforts to understand diversity biological system of the country and favor the access of this information to people who are fond of nature..

Endpoints Structure

"/province" --> GET method. To obtain all the information about locality. All the species that you can see in this location

"/province/comun --> GET method. To obtain all the species that you can find in a given locality

"/province/month" --> GET method. To obtain all the species that you can find in a given month

"/insert" --> POST method. to insert new species. Where it is mandatory that you indicate the location where you are (the name of town or city, the common name of the species, the scientific name, which class it belongs to and the date.

"/delete" --> POST method. Delete a given data. It is mandatory to introduce the _id

"/look" --> POST method. GET method. Returns the 10 localities closest to yo for see any species.

"/map" --> GET-POST method. returns a heatmap for a given taoxomic group.

Some examples of API calls:

To read all the species of a given province

("http://127.0.0.1:5000/province")

Returns: 
[{'_id': '6044ec0734b38296f136b6af'},
{'locality': 'Acantilados Jarama'},
{'species': 'Fringilla coeleb'},
{'common_name': 'Common Chaffinch'}]

To read information for a given species in a specific province

("http://127.0.0.1:5000/province/comun")

Returns:

[{'_id': '6044ec0734b38296f136b6b9'},
{'locality': 'Embalse de Pinilla'},
{'species': 'Podiceps cristatus'},
{'common_name': 'Somormujo lavanco'}]

To read infomation for a given species in a specific month

("http://127.0.0.1:5000/province/month")
Returns: 
[{"_id": {"$oid": "6049058ec744a637acfeca3f"},
"locality": "Acantilados Jarama",
"species": "Fringilla coelebs", 
"common_name": "Common Chaffinch"}]

Some results

This graph shows the number of data that has been added to the database by years for each of the classes of animals in the API. In general, it is observed that over the years more species have been added to our database, with the exception of Birds, which has decreased over the years.

species

The following figures show a characterization of the main predictor variables (maximum temperature, minimum temperature, elevation and precipitation) of the physical conditions for each of the localities that we include in the database.

Maximum temperature
temp_max
Minimum temperature
temp_min
Elevation
elevation
Precipitation
precip

Requirements to replicate the methodology

Requirements

requirements.txt

About

In this project you will find the code to create a Python API using Flask. The goal, to create an API that serves as data of species in Spain, where to find them, when to find them and create a model to predict where we can find species that are not in our database.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published