---
title: "Weather Data"
format:
  html:
    toc: true
    toc-depth: 2
    number-sections: true
    toc-location: left
    fig-cap-location: top
    code-fold: false
    code-tools: true
    theme: flatly
    page-layout: full
editor: visual
vignette: >
  %\VignetteIndexEntry{Weather Data}
  %\VignetteEngine{quarto::html}
  %\VignetteEncoding{UTF-8}
---

```{r, echo=FALSE, message=FALSE, warning=FALSE}
# Ensure the temporary library from R CMD check is visible (esp. on Windows)
libdir <- Sys.getenv("R_LIBS")
if (nzchar(libdir)) {
  parts <- strsplit(libdir, .Platform$path.sep, fixed = TRUE)[[1]]
  .libPaths(unique(c(parts, .libPaths())))
}

# now load your package
suppressPackageStartupMessages(library(ecotourism))
```

## Introduction

This vignette demonstrates the use of two datasets: `top_stations` and `weather`. After selecting an organism of interest, we linked each occurrence to its nearest weather station. We then counted the matches, identified the top three weather stations most closely associated with the organism’s occurrences, and downloaded the corresponding weather data for further analysis.

------------------------------------------------------------------------

This is the glimpse of your `top_stations` data :

```{r, echo=TRUE, eval=TRUE, message=FALSE, warning=FALSE}
library(dplyr)
library(ecotourism)

data("top_stations")
top_stations |> glimpse()
```

and this is `weather` data related to those top stations:

```{r, echo=TRUE, eval=TRUE, message=FALSE, warning=FALSE}

data("weather")
weather |> glimpse()
```

------------------------------------------------------------------------

Map of Top Weather Stations

```{r echo=TRUE, eval=FALSE, fig.width=6, fig.height=4, message=FALSE, warning=FALSE}
library(ggplot2)
library(ggthemes)

top_stations |> left_join(weather_stations) |> 
ggplot() +
  geom_sf(data = oz_lga) +
  geom_point(aes(x = stn_lon, y = stn_lat, color = organism), shape = 17, size = 3) +
  theme_map()
```

------------------------------------------------------------------------
