# add a column month
$month = month(as.POSIXlt(wildschwein_BE$DatetimeUTC,
wildschwein_BEformat="%Y-%m-%d"), label=TRUE,
abbr=FALSE)
# filter for May and June
<- wildschwein_BE |>
wild_summer filter(month == "May" | month == "June", .keep_all=TRUE)
# join with crop data
<- st_join(wild_summer, feld) data_joined
Week 6 Context
Task 1: Import and visualise spatial data
What information does the dataset contain?
- Which ID the field has, what crop is growing and the coordinates in metres.
What is the geometry type of the dataset (possible types are: Point, Lines and Polygons)?
- Polygons
What are the data types of the other columns?
- FieldID: double, Frucht: character
What is the coordinate system of the dataset?
- Projected CRS: CH1903+ / LV95
Task 2: Annotate Trajectories from vector data
Select May and June.
The following plot already shows that one of the wild boars (orange) resides in a different location than the other two.
Task 3: Explore annotated trajectories
Drop geometry. Create column hour. Aggregate column Frucht. Count data points on each Frucht polygon. Calculate percentage.
<- data_joined |>
data_joined na.omit() |>
st_drop_geometry() |>
mutate(hour = hour(round_date(DatetimeUTC, "hour")),
Frucht_group = forcats::fct_lump(Frucht, 4)) |>
group_by(TierName, hour, Frucht_group) |>
summarise(n=n()) |>
mutate(perc = n/sum(n))
Forest is preferred by all the wild boars. But whereas Ruth and Sabi also like wetlands, Rosa prefers barley.
Task 4: Import and visualise vegetationindex (raster data)
Task 5: Annotate Trajectories from raster data
The following plot shows that Rosa and Sabi reside more in higher vegetation compared to Ruth.
Change the column name as I couldn’t figure out how to change the legend title in the following plot.
colnames(wild_summer2)[colnames(wild_summer2)=="TierName"] <- "Wild Boar"
The following plot indicates again that the wild boar prefer higher vegetation but are not dependent on it (especially Rosa). I don’t know why there is a missing wild boar in the legend (used na.omit especially for that).