---
title: "Prepare data"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Prepare data}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
```{r setup}
library(impIndicator)
library(b3gbi)
library(sf)
```
## Process GBIF data from the R environment
1. import GBIF data using `read.csv()`, `readr::read_csv()`, or `readxl::read_excel()` based on the data set format.
Here is an example a GBIF occurrences data with the minimum required columns.`decimalLatitude`, `decimalLongitude`, `species`, `speciesKey`, `coordinateUncertaintyInMeters` and `year`
```{r echo=FALSE, results='asis'}
library(knitr)
taxa_Acacia %>% dplyr::select(decimalLatitude,
decimalLongitude,
species,
speciesKey,
coordinateUncertaintyInMeters,
year
) %>% head(10) %>%
kable()
```
The `region` of the study has to be given as a shapefile of the study area
or a character representing the country of study area . An example is:
```{r}
southAfrica_sf
```
```{r}
acacia_cube <- taxa_cube(
taxa = taxa_Acacia,
region = southAfrica_sf,
first_year = 2010,
last_year = 2023
)
```
The cube is a `sim_cube` object. Below is an example of the acacia taxa in
South Africa
```{r}
# view processed cube
acacia_cube
```
## Download from GBIF website
The cube can be generated by downloading the GBIF with `rgbif::occ_data()`
## Cube with stardard grid
**impIndicator** works other cubes with standard grid cell, such as, eea and eqdgc
which are processed from `b3gbi::process_cube()`. An example is the mammal_cube
in the `b3gbi` package.
```{r}
# Load GBIF data cube
cube_name <- system.file("extdata", "denmark_mammals_cube_eqdgc.csv", package = "b3gbi")
# Prepare cube
mammal_cube <- process_cube(cube_name,first_year = 2000)
# View cube
mammal_cube
```