-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpeciesLocationChecks.R
53 lines (43 loc) · 1.74 KB
/
SpeciesLocationChecks.R
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
###### Use deltafish to check species locations
library(deltafish)
library(sf)
library(leaflet)
# Download data ---------------------------------
create_fish_db()
surv <- open_survey()
fish <- open_fish()
surv_FMWT_DJFMP <- surv %>%
filter(source %in% c("SKT", "FMWT", "DJFMP", "STN", "TMM", "EDSM", "Suisun", "BayStudy", "SLS"))
fish_filter <- fish %>%
filter(Taxa %in% c("Oncorhynchus tshawytscha"))
df_salmon <- left_join(surv, fish_filter) %>%
collect()
# Filter data ------------------------------------
df_salmon2 <- df_salmon %>%
filter(Count>0)
hist(df_salmon2$Length) # looks like only juvenile salmon are in here
# Make a map of stations ----------------------------
locations <- df_salmon2 %>%
select(Survey, Station, Latitude, Longitude) %>%
distinct() %>%
filter(!is.na(Latitude))
# make sf if we want to make a static map
locations_sf <- st_as_sf(locations, coords = c("Longitude", "Latitude"), crs = 4326)
regions <- st_read("RosieRegions/shpExport.shp")
regions$Region <- c("Suisun Marsh", "Suisun Bay","Confluence", "North Delta", "Far North", "Central" , "South")
# But lets just use leaflet
pal <- colorFactor(viridis::viridis(9), locations$Survey)
locations %>% # call data frame.
leaflet() %>% # call leaflet.
addTiles() %>% # this adds the map in the background.
addCircleMarkers(
color = ~pal(Survey),
stroke = FALSE, # alters whether there is a border to circle
fillOpacity = 0.8,
radius = 1.5,
lng = ~Longitude, # call your longitude column name
lat = ~Latitude, # call you latitude column name
label = ~paste(Station, "Lat:", Latitude, "Long:", Longitude)) %>% # edit what you want to show up in your label
addLegend(pal = pal,
values = ~Survey,
position = "bottomright")