-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Rhistory
512 lines (512 loc) · 27.4 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
# Print the number of observations included
num_points <- nrow(cat1_observations)
print(paste("Number of points in cat1:", num_points))
# Save the plot
ggsave(species_plot_cat1, file = "~/GitHub/craywatch/R/data/output/craywatch_maps/cat1_craywatch_map.png",
width = 15, height = 6.4, units = "cm", dpi = 200)
View(cat1_waterlopen_in_vlaanderen)
#R - libraries
library(ggspatial)
library(sf)
library(tidyverse)
library(dplyr)
library(scales)
library(osmdata)
library(ggplot2)
library(tidyr)
library(lubridate)
# Read data
craywatch_data <- read.csv("~/GitHub/craywatch/R/data/observations/data_validation/craywatch_validation.csv")
map_data <- read.csv("~/GitHub/craywatch/assets/localities.csv")
# Ensure the 'date' column is in the correct Date format (assuming day-month-year format)
craywatch_data$date <- dmy(craywatch_data$date) # Convert to Date using dmy format
# Group by locID and process data
grouped_craywatch_data <- craywatch_data %>%
group_by(locID) %>%
summarize(
number_of_individuals = sum(number.of.individuals, na.rm = TRUE),
number_of_days = n(), # Rename count
start_date = min(date, na.rm = TRUE), # Get the first date
end_date = max(date, na.rm = TRUE), # Get the last date
species = list(
if (sum(number.of.individuals, na.rm = TRUE) > 0) unique(soort[number.of.individuals > 0]) else "absent"
), # Capture species or 'absent'
consecutive = {
# Check if the dates are consecutive for each locID
date_diff <- diff(sort(unique(date))) # Calculate the differences between sorted unique dates
all(date_diff == 1) # TRUE if all differences are 1, meaning consecutive days
},
vrijwillID = first(vrijwillID) # Take the first 'vrijwillID' value for each group (assuming it is the same for each group)
) %>%
unnest(cols = c(species)) # Separate each species into its own row
# Select only the 'locID', 'Latitude', and 'Longitude' columns from localities
localities_selected <- map_data %>%
dplyr::select(locID, Latitude, Longitude)
# Merge with localities to add Latitude and Longitude based on locID
grouped_craywatch_data <- left_join(grouped_craywatch_data, localities_selected, by = "locID")
#preview new data
head(grouped_craywatch_data) # Show the first few rows of the data
# Inspect the structure of the dataset to check for lat/long columns
str(grouped_craywatch_data)
# Nagaan hoeveel mensen exact het protocol volgden
protocol_followers <- grouped_craywatch_data %>%
filter(number_of_days == 4 & consecutive == "TRUE") # locaties waar er exact 4 na elkaar dagen gecontroleerd is
n_distinct(protocol_followers$vrijwillID)
# Filter the data we want to use
craywatch_data_usable <- grouped_craywatch_data %>%
filter(!is.na(Longitude) & !is.na(Latitude)) %>%
filter(!(species == "absent" & number_of_days < 4)) # Exclude rows where species is "absent" and number_of_days < 4
craywatch_sf <- st_as_sf(craywatch_data_usable, coords = c("Longitude", "Latitude"), crs = 4326)
# Read shapefiles
vlaanderen <- st_read("~/GitHub/craywatch/R/data/input/shapefiles/grenzenvlaanderen.shp")
hoofdrivieren <- st_read("~/GitHub/craywatch/R/data/input/shapefiles/hoofdrivieren.shp")
kanalen <- st_read("~/GitHub/craywatch/R/data/input/shapefiles/kanalen.shp")
gemeenten <- st_read("~/GitHub/craywatch/R/data/input/shapefiles/gemeenten.shp")
# Zorg dat alle shapefiles dezelfde CRS hebben
vlaanderen <- st_transform(vlaanderen, st_crs(hoofdrivieren))
hoofdrivieren <- st_transform(hoofdrivieren, st_crs(vlaanderen))
kanalen <- st_transform(kanalen, st_crs(vlaanderen))
gemeenten <- st_transform(gemeenten, st_crs(vlaanderen))
# Clip de shapefiles tot de grenzen van Vlaanderen
hoofdrivieren_in_vlaanderen <- st_intersection(hoofdrivieren, vlaanderen)
kanalen_in_vlaanderen <- st_intersection(kanalen, vlaanderen)
gemeenten_in_vlaanderen <- st_intersection(gemeenten, vlaanderen)
sf_use_s2(FALSE)
# Make plot
base_plot <- ggplot() +
geom_sf(data = vlaanderen, fill= "lightgrey", size=0.2, colour= "black") +
geom_sf(data = hoofdrivieren_in_vlaanderen, size=0.1, colour="#4682B4")+
geom_sf(data = kanalen_in_vlaanderen, size=0.1, colour="#4682B4")+
theme_void() +
theme(legend.title = element_blank(),
legend.text=element_text(size=8, face="italic"),
legend.key.size = unit(0.2, "cm"),
legend.position = "bottom",
plot.title= element_text(face = "italic")) +
coord_sf()
# Make plot
gemeente_plot <- ggplot() +
geom_sf(data = vlaanderen, fill= "#98AF93", size=0.2, colour= "black") +
geom_sf(data = gemeenten_in_vlaanderen, size=0.1, colour="grey")+
geom_sf(data = hoofdrivieren_in_vlaanderen, size=0.1, colour="#4682B4")+
geom_sf(data = kanalen_in_vlaanderen, size=0.1, colour="#4682B4")+
theme_void() +
theme(legend.title = element_blank(),
legend.text=element_text(size=8, face="italic"),
legend.key.size = unit(0.2, "cm"),
legend.position = "bottom",
plot.title= element_text(face = "italic")) +
coord_sf()
# Define a color palette for species
species_colors <- c("faxonius limosus" = "#FFD700",
"procambarus clarkii" = "#FF0000", "procambarus virginalis" = "#FF00FF",
"faxonius virilis" = "#FFA500", "procambarus acutus" = "#000000", "absent" = "darkgrey")
# Update the legend labels for species with italic formatting
species_labels <- c( "faxonius limosus" = expression(italic("Faxonius limosus")),
"procambarus clarkii" = expression(italic("Procambarus clarkii")),
"procambarus virginalis" = expression(italic("Procambarus virginalis")),
"faxonius virilis" = expression(italic("Faxonius virilis")),
"procambarus acutus" = expression(italic("Procambarus acutus")),
"absent" = expression(italic("Absence")))
# Update the legend labels for species in Dutch
species_labels_dutch <- c( "faxonius limosus" = expression("gevlekte Amerikaanse rivierkreeft"),
"procambarus clarkii" = expression("rode Amerikaanse rivierkreeft"),
"procambarus virginalis" = expression("marmerkreeft"),
"faxonius virilis" = expression("geknobbelde Amerikaanse rivierkreeft"),
"procambarus acutus" = expression("gestreepte Amerikaanse rivierkreeft"),
"absent" = expression("afwezigheid"))
# Create a color scale with updated labels
color_scale <- scale_color_manual(values = species_colors, labels = species_labels)
# Create a color scale with updated labels in Dutch
color_scale_dutch <- scale_color_manual(values = species_colors, labels = species_labels_dutch)
# Separate the data for 'crayfish.indet' (absence) and other species
crayfish_indet_sf <- craywatch_sf %>% filter(species == "absent")
other_species_sf <- craywatch_sf %>% filter(species != "absent")
# Plot 'crayfish.indet' (absence) points first, then other species
species_plot <- base_plot +
geom_sf(data = crayfish_indet_sf, aes(color = species), size = 1) + # lightgrey (absence) points
geom_sf(data = other_species_sf, aes(color = species), size = 1) + # other species points
color_scale # Apply the color scale based on species
# Plot craywatch map with municipalities
species_plot_gemeente <- gemeente_plot +
geom_sf(data = crayfish_indet_sf, aes(color = species), size = 1) + # lightgrey (absence) points
geom_sf(data = other_species_sf, aes(color = species), size = 1) + # other species points
color_scale # Apply the color scale based on species
# Plot craywatch map with municipalities
species_plot_dutch <- gemeente_plot +
geom_sf(data = crayfish_indet_sf, aes(color = species), size = 1) + # lightgrey (absence) points
geom_sf(data = other_species_sf, aes(color = species), size = 1) + # other species points
color_scale_dutch # Apply the color scale based on species
# Save the plot
ggsave(species_plot, file = "~/GitHub/craywatch/R/data/output/craywatch_maps/validated_craywatch_map.png",
width = 15, height = 6.4, units = "cm", dpi = 200)
# Save the plot (gemeente)
ggsave(species_plot_gemeente, file = "~/GitHub/craywatch/R/data/output/craywatch_maps/validated_craywatch_map_gemeenten.png",
width = 15, height = 6.4, units = "cm", dpi = 200)
# Save the plot (Dutch)
ggsave(species_plot_dutch, file = "~/GitHub/craywatch/R/data/output/craywatch_maps/validated_craywatch_map_dutch.png",
width = 15, height = 6.4, units = "cm", dpi = 200)
# Sla het ggplot-object op
dir.create("./data/output/SelectedMunic", showWarnings = FALSE, recursive = TRUE)
saveRDS(species_plot_gemeente, "./data/output/SelectedMunic/species_plot.rds")
# Print the number of points included after filtering
num_points <- nrow(craywatch_data_usable)
print(paste("Number of points included in the map:", num_points))
# Sla finale Craywatch data op als een CSV-bestand
write.csv(craywatch_data_usable, "~/GitHub/craywatch/R/data/output/final_craywatch_data_2024.csv", row.names = FALSE)
library(colorspace)
original_color <- "#4682B4"
lighter_color <- lighten(original_color, amount = 0.3) # Adjust `amount` to control lightness
print(lighter_color)
# Make plot
base_plot <- ggplot() +
geom_sf(data = vlaanderen, fill= "lightgrey", size=0.2, colour= "black") +
geom_sf(data = hoofdrivieren_in_vlaanderen, size=0.1, colour="#4682B4")+
geom_sf(data = kanalen_in_vlaanderen, size=0.1, colour="#4682B4")+
theme_void() +
theme(legend.title = element_blank(),
legend.text=element_text(size=8, face="italic"),
legend.key.size = unit(0.2, "cm"),
legend.position = "bottom",
plot.title= element_text(face = "italic")) +
coord_sf()
# Make plot
gemeente_plot <- ggplot() +
geom_sf(data = vlaanderen, fill= "#98AF93", size=0.2, colour= "black") +
geom_sf(data = gemeenten_in_vlaanderen, size=0.1, colour="grey")+
geom_sf(data = hoofdrivieren_in_vlaanderen, size=0.1, colour="#72A7DA")+
geom_sf(data = kanalen_in_vlaanderen, size=0.1, colour="#72A7DA")+
theme_void() +
theme(legend.title = element_blank(),
legend.text=element_text(size=8, face="italic"),
legend.key.size = unit(0.2, "cm"),
legend.position = "bottom",
plot.title= element_text(face = "italic")) +
coord_sf()
# Define a color palette for species
species_colors <- c("faxonius limosus" = "#FFD700",
"procambarus clarkii" = "#FF0000", "procambarus virginalis" = "#FF00FF",
"faxonius virilis" = "#FFA500", "procambarus acutus" = "#000000", "absent" = "darkgrey")
# Update the legend labels for species with italic formatting
species_labels <- c( "faxonius limosus" = expression(italic("Faxonius limosus")),
"procambarus clarkii" = expression(italic("Procambarus clarkii")),
"procambarus virginalis" = expression(italic("Procambarus virginalis")),
"faxonius virilis" = expression(italic("Faxonius virilis")),
"procambarus acutus" = expression(italic("Procambarus acutus")),
"absent" = expression(italic("Absence")))
# Update the legend labels for species in Dutch
species_labels_dutch <- c( "faxonius limosus" = expression("gevlekte Amerikaanse rivierkreeft"),
"procambarus clarkii" = expression("rode Amerikaanse rivierkreeft"),
"procambarus virginalis" = expression("marmerkreeft"),
"faxonius virilis" = expression("geknobbelde Amerikaanse rivierkreeft"),
"procambarus acutus" = expression("gestreepte Amerikaanse rivierkreeft"),
"absent" = expression("afwezigheid"))
# Create a color scale with updated labels
color_scale <- scale_color_manual(values = species_colors, labels = species_labels)
# Create a color scale with updated labels in Dutch
color_scale_dutch <- scale_color_manual(values = species_colors, labels = species_labels_dutch)
# Separate the data for 'crayfish.indet' (absence) and other species
crayfish_indet_sf <- craywatch_sf %>% filter(species == "absent")
other_species_sf <- craywatch_sf %>% filter(species != "absent")
# Plot 'crayfish.indet' (absence) points first, then other species
species_plot <- base_plot +
geom_sf(data = crayfish_indet_sf, aes(color = species), size = 1) + # lightgrey (absence) points
geom_sf(data = other_species_sf, aes(color = species), size = 1) + # other species points
color_scale # Apply the color scale based on species
# Plot craywatch map with municipalities
species_plot_gemeente <- gemeente_plot +
geom_sf(data = crayfish_indet_sf, aes(color = species), size = 1) + # lightgrey (absence) points
geom_sf(data = other_species_sf, aes(color = species), size = 1) + # other species points
color_scale # Apply the color scale based on species
# Plot craywatch map with municipalities
species_plot_dutch <- gemeente_plot +
geom_sf(data = crayfish_indet_sf, aes(color = species), size = 1) + # lightgrey (absence) points
geom_sf(data = other_species_sf, aes(color = species), size = 1) + # other species points
color_scale_dutch # Apply the color scale based on species
# Save the plot
ggsave(species_plot, file = "~/GitHub/craywatch/R/data/output/craywatch_maps/validated_craywatch_map.png",
width = 15, height = 6.4, units = "cm", dpi = 200)
# Save the plot (gemeente)
ggsave(species_plot_gemeente, file = "~/GitHub/craywatch/R/data/output/craywatch_maps/validated_craywatch_map_gemeenten.png",
width = 15, height = 6.4, units = "cm", dpi = 200)
# Save the plot (Dutch)
ggsave(species_plot_dutch, file = "~/GitHub/craywatch/R/data/output/craywatch_maps/validated_craywatch_map_dutch.png",
width = 15, height = 6.4, units = "cm", dpi = 200)
# Sla het ggplot-object op
dir.create("./data/output/SelectedMunic", showWarnings = FALSE, recursive = TRUE)
saveRDS(species_plot_gemeente, "./data/output/SelectedMunic/species_plot.rds")
# Print the number of points included after filtering
num_points <- nrow(craywatch_data_usable)
print(paste("Number of points included in the map:", num_points))
# Sla finale Craywatch data op als een CSV-bestand
write.csv(craywatch_data_usable, "~/GitHub/craywatch/R/data/output/final_craywatch_data_2024.csv", row.names = FALSE)
library(colorspace)
original_color <- "#4682B4"
lighter_color <- lighten(original_color, amount = 0.5) # Adjust `amount` to control lightness
print(lighter_color)
original_color <- "#4682B4"
lighter_color <- lighten(original_color, amount = 0.2) # Adjust `amount` to control lightness
print(lighter_color)
original_color <- "#4682B4"
lighter_color <- lighten(original_color, amount = 0.25) # Adjust `amount` to control lightness
print(lighter_color)
# Make plot
gemeente_plot <- ggplot() +
geom_sf(data = vlaanderen, fill= "#98AF93", size=0.2, colour= "black") +
geom_sf(data = gemeenten_in_vlaanderen, size=0.1, colour="grey")+
geom_sf(data = hoofdrivieren_in_vlaanderen, size=0.1, colour="#6BA1D3")+
geom_sf(data = kanalen_in_vlaanderen, size=0.1, colour="#6BA1D3")+
theme_void() +
theme(legend.title = element_blank(),
legend.text=element_text(size=8, face="italic"),
legend.key.size = unit(0.2, "cm"),
legend.position = "bottom",
plot.title= element_text(face = "italic")) +
coord_sf()
# Define a color palette for species
species_colors <- c("faxonius limosus" = "#FFD700",
"procambarus clarkii" = "#FF0000", "procambarus virginalis" = "#FF00FF",
"faxonius virilis" = "#FFA500", "procambarus acutus" = "#000000", "absent" = "darkgrey")
# Update the legend labels for species with italic formatting
species_labels <- c( "faxonius limosus" = expression(italic("Faxonius limosus")),
"procambarus clarkii" = expression(italic("Procambarus clarkii")),
"procambarus virginalis" = expression(italic("Procambarus virginalis")),
"faxonius virilis" = expression(italic("Faxonius virilis")),
"procambarus acutus" = expression(italic("Procambarus acutus")),
"absent" = expression(italic("Absence")))
# Update the legend labels for species in Dutch
species_labels_dutch <- c( "faxonius limosus" = expression("gevlekte Amerikaanse rivierkreeft"),
"procambarus clarkii" = expression("rode Amerikaanse rivierkreeft"),
"procambarus virginalis" = expression("marmerkreeft"),
"faxonius virilis" = expression("geknobbelde Amerikaanse rivierkreeft"),
"procambarus acutus" = expression("gestreepte Amerikaanse rivierkreeft"),
"absent" = expression("afwezigheid"))
# Create a color scale with updated labels
color_scale <- scale_color_manual(values = species_colors, labels = species_labels)
# Create a color scale with updated labels in Dutch
color_scale_dutch <- scale_color_manual(values = species_colors, labels = species_labels_dutch)
# Separate the data for 'crayfish.indet' (absence) and other species
crayfish_indet_sf <- craywatch_sf %>% filter(species == "absent")
other_species_sf <- craywatch_sf %>% filter(species != "absent")
# Plot 'crayfish.indet' (absence) points first, then other species
species_plot <- base_plot +
geom_sf(data = crayfish_indet_sf, aes(color = species), size = 1) + # lightgrey (absence) points
geom_sf(data = other_species_sf, aes(color = species), size = 1) + # other species points
color_scale # Apply the color scale based on species
# Plot craywatch map with municipalities
species_plot_gemeente <- gemeente_plot +
geom_sf(data = crayfish_indet_sf, aes(color = species), size = 1) + # lightgrey (absence) points
geom_sf(data = other_species_sf, aes(color = species), size = 1) + # other species points
color_scale # Apply the color scale based on species
# Plot craywatch map with municipalities
species_plot_dutch <- gemeente_plot +
geom_sf(data = crayfish_indet_sf, aes(color = species), size = 1) + # lightgrey (absence) points
geom_sf(data = other_species_sf, aes(color = species), size = 1) + # other species points
color_scale_dutch # Apply the color scale based on species
# Save the plot
ggsave(species_plot, file = "~/GitHub/craywatch/R/data/output/craywatch_maps/validated_craywatch_map.png",
width = 15, height = 6.4, units = "cm", dpi = 200)
# Save the plot (gemeente)
ggsave(species_plot_gemeente, file = "~/GitHub/craywatch/R/data/output/craywatch_maps/validated_craywatch_map_gemeenten.png",
width = 15, height = 6.4, units = "cm", dpi = 200)
# Save the plot (Dutch)
ggsave(species_plot_dutch, file = "~/GitHub/craywatch/R/data/output/craywatch_maps/validated_craywatch_map_dutch.png",
width = 15, height = 6.4, units = "cm", dpi = 200)
# Sla het ggplot-object op
dir.create("./data/output/SelectedMunic", showWarnings = FALSE, recursive = TRUE)
saveRDS(species_plot_gemeente, "./data/output/SelectedMunic/species_plot.rds")
# Print the number of points included after filtering
num_points <- nrow(craywatch_data_usable)
print(paste("Number of points included in the map:", num_points))
# Sla finale Craywatch data op als een CSV-bestand
write.csv(craywatch_data_usable, "~/GitHub/craywatch/R/data/output/final_craywatch_data_2024.csv", row.names = FALSE)
library(scales)
original_color <- "#4682B4"
lighter_color <- scales::muted(original_color, l = 90) # Adjust `l` for lightness
print(lighter_color)
original_color <- "#4682B4"
lighter_color <- scales::muted(original_color, l = 30) # Adjust `l` for lightness
print(lighter_color)
# Make plot
base_plot <- ggplot() +
geom_sf(data = vlaanderen, fill= "lightgrey", size=0.2, colour= "black") +
geom_sf(data = hoofdrivieren_in_vlaanderen, size=0.1, colour="#6BA1D3")+
geom_sf(data = kanalen_in_vlaanderen, size=0.1, colour="#6BA1D3")+
theme_void() +
theme(legend.title = element_blank(),
legend.text=element_text(size=8, face="italic"),
legend.key.size = unit(0.2, "cm"),
legend.position = "bottom",
plot.title= element_text(face = "italic")) +
coord_sf()
# Make plot
gemeente_plot <- ggplot() +
geom_sf(data = vlaanderen, fill= "#98AF93", size=0.2, colour= "black") +
geom_sf(data = gemeenten_in_vlaanderen, size=0.1, colour="grey")+
geom_sf(data = hoofdrivieren_in_vlaanderen, size=0.1, colour="#6BA1D3")+
geom_sf(data = kanalen_in_vlaanderen, size=0.1, colour="#6BA1D3")+
theme_void() +
theme(legend.title = element_blank(),
legend.text=element_text(size=8, face="italic"),
legend.key.size = unit(0.2, "cm"),
legend.position = "bottom",
plot.title= element_text(face = "italic")) +
coord_sf()
# Define a color palette for species
species_colors <- c("faxonius limosus" = "#FFD700",
"procambarus clarkii" = "#FF0000", "procambarus virginalis" = "#FF00FF",
"faxonius virilis" = "#FFA500", "procambarus acutus" = "#000000", "absent" = "darkgrey")
# Update the legend labels for species with italic formatting
species_labels <- c( "faxonius limosus" = expression(italic("Faxonius limosus")),
"procambarus clarkii" = expression(italic("Procambarus clarkii")),
"procambarus virginalis" = expression(italic("Procambarus virginalis")),
"faxonius virilis" = expression(italic("Faxonius virilis")),
"procambarus acutus" = expression(italic("Procambarus acutus")),
"absent" = expression(italic("Absence")))
# Update the legend labels for species in Dutch
species_labels_dutch <- c( "faxonius limosus" = expression("gevlekte Amerikaanse rivierkreeft"),
"procambarus clarkii" = expression("rode Amerikaanse rivierkreeft"),
"procambarus virginalis" = expression("marmerkreeft"),
"faxonius virilis" = expression("geknobbelde Amerikaanse rivierkreeft"),
"procambarus acutus" = expression("gestreepte Amerikaanse rivierkreeft"),
"absent" = expression("afwezigheid"))
# Create a color scale with updated labels
color_scale <- scale_color_manual(values = species_colors, labels = species_labels)
# Create a color scale with updated labels in Dutch
color_scale_dutch <- scale_color_manual(values = species_colors, labels = species_labels_dutch)
# Separate the data for 'crayfish.indet' (absence) and other species
crayfish_indet_sf <- craywatch_sf %>% filter(species == "absent")
other_species_sf <- craywatch_sf %>% filter(species != "absent")
# Plot 'crayfish.indet' (absence) points first, then other species
species_plot <- base_plot +
geom_sf(data = crayfish_indet_sf, aes(color = species), size = 1) + # lightgrey (absence) points
geom_sf(data = other_species_sf, aes(color = species), size = 1) + # other species points
color_scale # Apply the color scale based on species
# Plot craywatch map with municipalities
species_plot_gemeente <- gemeente_plot +
geom_sf(data = crayfish_indet_sf, aes(color = species), size = 1) + # lightgrey (absence) points
geom_sf(data = other_species_sf, aes(color = species), size = 1) + # other species points
color_scale # Apply the color scale based on species
# Plot craywatch map with municipalities
species_plot_dutch <- gemeente_plot +
geom_sf(data = crayfish_indet_sf, aes(color = species), size = 1) + # lightgrey (absence) points
geom_sf(data = other_species_sf, aes(color = species), size = 1) + # other species points
color_scale_dutch # Apply the color scale based on species
# Save the plot
ggsave(species_plot, file = "~/GitHub/craywatch/R/data/output/craywatch_maps/validated_craywatch_map.png",
width = 15, height = 6.4, units = "cm", dpi = 200)
# Save the plot (gemeente)
ggsave(species_plot_gemeente, file = "~/GitHub/craywatch/R/data/output/craywatch_maps/validated_craywatch_map_gemeenten.png",
width = 15, height = 6.4, units = "cm", dpi = 200)
# Save the plot (Dutch)
ggsave(species_plot_dutch, file = "~/GitHub/craywatch/R/data/output/craywatch_maps/validated_craywatch_map_dutch.png",
width = 15, height = 6.4, units = "cm", dpi = 200)
# Sla het ggplot-object op
dir.create("./data/output/SelectedMunic", showWarnings = FALSE, recursive = TRUE)
saveRDS(species_plot_gemeente, "./data/output/SelectedMunic/species_plot.rds")
# Print the number of points included after filtering
num_points <- nrow(craywatch_data_usable)
print(paste("Number of points included in the map:", num_points))
# Sla finale Craywatch data op als een CSV-bestand
write.csv(craywatch_data_usable, "~/GitHub/craywatch/R/data/output/final_craywatch_data_2024.csv", row.names = FALSE)
# read data
final_craywatch_data <- read.csv("~/GitHub/craywatch/R/data/output/final_craywatch_data_2024.csv")
#read shapefiles
waterlopen <- st_read("~/GitHub/craywatch/R/data/input/shapefiles/provincies.shp")
colnames(provincies)
# Laad benodigde libraries
library(sf)
library(dplyr)
# Laad datasets
final_craywatch_data <- read.csv("~/GitHub/craywatch/R/data/output/final_craywatch_data_2024.csv")
provincies <- st_read("~/GitHub/craywatch/R/data/input/shapefiles/provincies.shp")
colna
colnames(provincies)
# Laad benodigde libraries
library(sf)
library(dplyr)
# Laad datasets
final_craywatch_data <- read.csv("~/GitHub/craywatch/R/data/output/final_craywatch_data_2024.csv")
provincies <- st_read("~/GitHub/craywatch/R/data/input/shapefiles/provincies.shp")
colnames(provincies)
# Controleer en zorg dat CRS gelijk is
provincies <- st_transform(provincies, crs = st_crs(provincies))
craywatch_sf <- st_as_sf(final_craywatch_data, coords = c("Longitude", "Latitude"), crs = st_crs(provincies))
# Ruimtelijke join: koppel craywatch-punten aan provincies
punten_in_provincies <- st_join(craywatch_sf, provincies, join = st_within)
# Tel punten per provincie
punten_per_provincie <- punten_in_provincies %>%
group_by(PROVNAAM) %>%
summarise(aantal_punten = n())
# Bekijk resultaten
print(punten_per_provincie)
# Controleer en zorg dat CRS gelijk is
provincies <- st_transform(provincies, crs = st_crs(provincies))
craywatch_sf <- st_as_sf(final_craywatch_data, coords = c("Longitude", "Latitude"), crs = st_crs(provincies))
craywatch_sf <- st_transform(craywatch_sf, crs = st_crs(provincies))
# Laad datasets
final_craywatch_data <- read.csv("~/GitHub/craywatch/R/data/output/final_craywatch_data_2024.csv")
provincies <- st_read("~/GitHub/craywatch/R/data/input/shapefiles/provincies.shp")
colnames(provincies)
# Controleer en zorg dat CRS gelijk is
provincies <- st_transform(provincies, crs = st_crs(provincies))
craywatch_sf <- st_as_sf(final_craywatch_data, coords = c("Longitude", "Latitude"), crs = 4326)
craywatch_sf <- st_transform(craywatch_sf, crs = st_crs(provincies))
# Ruimtelijke join: koppel craywatch-punten aan provincies
punten_in_provincies <- st_join(craywatch_sf, provincies, join = st_within)
# Tel punten per provincie
punten_per_provincie <- punten_in_provincies %>%
group_by(PROVNAAM) %>%
summarise(aantal_punten = n())
# Bekijk resultaten
print(punten_per_provincie)
library(sf)
# Maak een sf-object met het punt
point <- st_sfc(st_point(c(248665, 207795)), crs = 31370) # Stel CRS in als Belgian Lambert 72
# Transformeer het punt naar WGS 84 (EPSG:4326)
point_wgs84 <- st_transform(point, crs = 4326)
# Bekijk de coördinaten
coordinates <- st_coordinates(point_wgs84)
print(coordinates)
load("~/GitHub/craywatch/R/data/output/processed_data.RData")
# Suppress messages and warnings and prevent output display
knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE)
# Load the processed data
load("../data/output/processed_data.RData")
# Suppress messages and warnings and prevent output display
knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE)
knitr::include_graphics("https://imgur.com/7g3eJVw.jpg")
---
output:
html_document:
theme: null
knitr::include_graphics(~/GitHub/craywatch/assets/images/happy_holidays_crayfish.webp)
knitr::include_graphics("~/GitHub/craywatch/assets/images/happy_holidays_crayfish.webp")
library(knitr)
data <- data.frame(
Kolom1 = c("1200 kreeftenvallen", "3000 meter touw", ">100 kg hondenvoer als lokaas", "2500 aaszakjes", "1600 Craywatch labels")
)
kable(data)
library(knitr)
data <- data.frame(
Materiaal = c("1200 kreeftenvallen", "3000 meter touw", ">100 kg hondenvoer als lokaas", "2500 aaszakjes", "1600 Craywatch labels")
)
kable(data)
knitr::include_graphics("~/GitHub/craywatch/R/data/output/craywatch_maps/validated_craywatch_map_dutch.png")
knitr::include_graphics("~/GitHub/craywatch/assets/images/virilis_nieuwsbrief.jpg")
knitr::include_graphics(image_links$banner_bottom)
knitr::include_graphics("~/GitHub/craywatch/assets/images/craywatch_banner.jpg")
# Suppress messages and warnings and prevent output display
knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE)
# Load the processed data
load("~/GitHub/craywatch/R/data/output/processed_data.RData")
# Suppress messages and warnings and prevent output display
knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE)
# Load the processed data
load("~/GitHub/craywatch/R/data/output/processed_data.RData")
knitr::include_graphics(image_links$banner_bottom)
knitr::include_graphics(image_links$banner_bottom)
setwd("~/GitHub/craywatch/assets/images")
setwd("~/GitHub/craywatch")
knitr::include_graphics("~/GitHub/craywatch/assets/images/happy_holidays_crayfish.webp")
knitr::include_graphics("~/GitHub/craywatch/R/data/output/craywatch_maps/validated_craywatch_map_dutch.png")