Closed Anuragsahucuraj closed 1 year ago
Morning,
I think that part of the openair book is out of date - clust$data now has two objects within it. The correct code looks like the below. We'll look to get that fixed asap!
library(openair)
traj <- importTraj(site = "london", year = 2011)
kc1 <- importAURN(site = "kc1", year = 2011)
clust <- trajCluster(
traj,
method = "Angle",
n.cluster = 6,
col = "Set2",
map.cols = openColours("Paired", 10),
plot = FALSE
)
#> Warning in trajCluster(traj, method = "Angle", n.cluster = 6, col = "Set2", :
#> Trajectory lengths differ, using most common length.
trajPlot(clust$data$traj, group = "cluster")
Created on 2023-08-31 with reprex v2.0.2
As far as shifting the scales to the side of the plot, trajPlot()
does not have that option, sadly. We have a function in {openairmaps}
that may help, however:
library(openairmaps)
clustdata <- openair::trajCluster(traj_data, plot = FALSE)
trajMapStatic(data = clustdata$data$traj,
colour = "cluster") +
ggplot2::scale_color_manual(values = c("#9B5DE5", "#F15BB5", "#FEE440", "#00BBF9", "#00F5D4"))
Created on 2023-08-31 with reprex v2.0.2
Thank you Now i got it
I also want to plot cluster of a pollutant like BLACK CARBON I plotted cluster of all air mass trajectories. How can i plot cluster of a pollutant?
I am trying to plot (Chapter 10(10.8)) the concentration of each cluster.
What I did
For that, i am following Chapter 10 (10.8 Trajectory Clustering) i followed step by step After marked a variable with the name clust and stored all the back trajectory information into that variable. I am trying to plot the clust variable using the #trajplot function i am getting error continuously the error is
This is my code clust <-trajCluster(BackTraj, method = "Euclid", n.cluster = 4, plot = TRUE ,cols = c("yellow", "green", "blue", "red"), split.after = FALSE, xlim=c(40,100),ylim=c(0,50), map.fill = FALSE, map.cols = "transparent", map.alpha = 0.4, projection = "lambert", parameters = c(10, 120), orientation = c(0,120,0), by.type = TRUE, origin = TRUE, lwd=6, grid.col="grey40", grid.alpha=0.2, font.label= c(16, "bold", "red"))
whitout clust variable its showing the plot but when i am trying to plot using clust variable its showing error.
i checked the clust variable inside that lat lon hour.inc hight cluster are showing but while plotting its showing Can't find the variable(s) date lat lon hour.inc height cluster Error in checkPrep(mydata, vars, type, remove.calm = FALSE) :
and also how can i shift the xlim and ylim scale position to the side of the plot
Please resolve my issue.
Thank you