-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Rhistory
65 lines (65 loc) · 2.41 KB
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
setwd("C:/Users/Dan/Documents/PhD/Dispersal/github/portunid_particle_tracking")
# Load the ozroms bathymetry data
bathy <- tidync("Data/bathymetry.nc") %>% hyper_tibble()
library(tidync)
library(tidyverse)
library(ggplot2)
library(rnaturalearth)
library(sf)
setwd("C:/Users/Dan/Documents/PhD/Dispersal/github/portunid_particle_tracking")
# Load the ozroms bathymetry data
bathy <- tidync("Data/bathymetry.nc") %>% hyper_tibble()
oz <- ne_states(country = "australia", returnclass = "sf")
# load a velocities file
vel.file <- hyper_tibble("Data/20150101.nc")
# select the non-NaN velocity cells (i.e. the ones that are in the ocean)
vel.file <- vel.file %>%
filter(u != is.nan(u))
# use that to select from the bathy file
lon <- unique(vel.file$lon)
shelf <- data.frame()
for (i in 1:length(lon)){
temp <- bathy %>% filter(lon == lon[i])
shelf <- bind_rows(shelf, temp)
}
shelf <- shelf %>%
# first pass at selecting the shelf
filter(h < 200 & h > 15) %>%
# remove shallow areas that aren't on the shelf
filter(lon < 155) %>%
filter(!lon > 149.5 | !lat > -18) %>%
filter(!lon > 151.5 | !lat > -20) %>%
filter(!lon > 153.5 | !lat > -22.5)
# set up the ocean_zone column
ocean_zones <- data.frame(max_lat = seq(-15, -37, by = -1), min_lat = seq(-16, -38, by = -1))
ocean_zones <- ocean_zones %>%
#mutate(state = if_else(min_lat < -28, "NSW", "QLD")) %>%
#group_by(state) %>%
mutate(zone_number = row_number()) %>%
ungroup() %>%
mutate(ocean_zone = zone_number) %>%
select(max_lat, min_lat, ocean_zone)
# gmc
gmc.locations <- shelf %>%
mutate(max_lat = as.numeric(substr(lat, 1, 3))) %>%
left_join(ocean_zones) %>%
select(lon, lat, ocean_zone) %>%
filter(lat > -34)
# bsc
bsc.locations <- shelf %>%
mutate(max_lat = as.numeric(substr(lat, 1, 3))) %>%
left_join(ocean_zones) %>%
select(lon, lat, ocean_zone) %>%
filter(lat > -35 & lat < -23)
# spanner crab
spanner.locations <- shelf %>%
filter(lat > -29.428612 & lat < -23) %>%
#filter(h < 100 & h > 15) %>%
mutate(ocean_zone = if_else(lat < -23 & lat > -24, 2,
if_else(lat < -24 & lat > -25, 3,
if_else(lat < -25 & lat > -26.5, 4,
if_else(lat < -26.5 & lat > -27.5, 5,
if_else(lat < -27.5 & lat > -28.1643, 6,
if_else(lat < -28.1643 & lat > -29.428612, 7, 9999)))))))
write_csv(spanner.locations, "C:/Users/Dan/Documents/PhD/Dispersal/data_processed/spanner_possible_locations.csv")
write_csv(spanner.locations, "C:/Users/Dan/Documents/PhD/Dispersal/github/portunid_particle_tracking/Data/spanner_possible_locations.csv")