Currently I am working with spatial data points. These data points are defined with (long, lat) coordinates and contain information of plastic concentrations in a water system. Since I am interested in the influence of wind direction on the spatial distribution of the plastics in the water system, I want to create polygons for different (wind) directions (e.g. North, north-east, east, etc). Afterwards I want couple the earlier mentioned data points to the polygons of the wind directions. For the latter part I already have an idea on how to fix it.
My current problem is that I am not sure how to create the spatial polygons for the (wind)directions. For sure it is possible to draw the polygons by hand, but the quality of this is questionable. Is there maybe an easier way to create these polygons>
library("sf")
library("raster")
library("sp")
library("spData")
library("spDataLarge")
library(tmap) # for static and interactive maps
library(leaflet) # for interactive maps
library(ggplot2) # tidyverse data visualization package
install.packages("rgdal") #importing KML files
library("rgdal")
(rgdal_show_exportToProj4_warnings="none")
library(dplyr)
library(stringr) # for working with strings (pattern matching)
library(tidyr)
#Load data for segments
Meet3 <- read.csv2("Weeklydata/Data Week 1/DataWeek1.csv", header = TRUE)
Lengte <- read.csv2("Weeklydata/Length.csv", header = TRUE)
segmenttest <- st_read("R maps/polygons/PolygonsLeiden.kml")
Meet3$Segments <- c("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","0")
PlasticData =Meet3[c(-30),]
PolOnly <- segmenttest[ ,1,3]
PolOnly$Segments <- c("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")
PolOnly$area <- st_area(PolOnly) #calculation of area
PolOnly$Length <- c(Lengte$Length)
#Combine data
PlasticMap = left_join(PlasticData, PolOnly)
PlasticMap = st_as_sf(PlasticMap, crs=st_crs(PolOnly))
PlasticMap$width <- c(PlasticMap$area/PlasticMap$Length)
PlasticMap$SegmentWidth <- c(PlasticMap$area/PlasticMap$Length)
#geometry
Plane <- st_centroid(PlasticMap$geometry)
PlasticMap$dir <- Plane
#map with total plastic in points
ap1 = tm_shape(PlasticMap, name = "dir") + tm_dots(size = "total.per.segment", col = blues9)
print(ap1)