forked from AdamWilsonLabEDU/2024-geo511-spatial-data-science-case-studies-geo511_casestudy_template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,47 @@ | ||
--- | ||
title: "Case Study 06" | ||
author: Your Name | ||
date: August 1, 2020 | ||
author: Tina Ni | ||
date: October 8, 2024 | ||
output: github_document | ||
--- | ||
|
||
```{r load packages} | ||
library(terra) | ||
library(spData) | ||
library(tidyverse) | ||
library(sf) | ||
library(ncdf4) | ||
library(ggplot2) | ||
``` | ||
|
||
```{r download data} | ||
download.file("https://crudata.uea.ac.uk/cru/data/temperature/absolute.nc","crudata.nc", method = "curl") | ||
``` | ||
|
||
```{r making data} | ||
#tmean is climate data | ||
tmean = rast ('crudata.nc') | ||
max_val_pix = max(tmean) | ||
max_temp_country <- terra::extract (max_val_pix, world, fun = max, na.rm = TRUE, small =T) | ||
world_clim <- bind_cols(world, max_temp_country) | ||
``` | ||
|
||
```{r plot data} | ||
ggplot(data = world_clim)+ | ||
geom_sf(aes(fill = max))+ | ||
scale_fill_viridis_c (name="Maximum/nTemperature (C)")+ | ||
theme(legend.position = 'bottom') | ||
``` | ||
|
||
```{r make table about hottest continents} | ||
hottest_continents <- world_clim |> | ||
group_by(continent)|> | ||
top_n(1,max)|> | ||
arrange(desc(max)) |> | ||
st_set_geometry(NULL) |> | ||
select(name_long,continent, max) | ||
hottest_continents | ||
``` |