setwd("C:/Users/s-das/Syncplicity Folders/155660--- Urban Freeway Fatality/NEW2")
tmc <- read.csv("TMC1.csv")
library(ggplot2)
library(ggrepel)
## Warning: package 'ggrepel' was built under R version 3.2.5
cbPalette <- c("#35274A", "#DC863B")
ggplot(tmc) +
geom_segment(aes(color= Direction, x=start_latitude, xend=end_latitude, y=start_longitude, yend=end_longitude), size=1,
arrow=arrow(length=unit(0.4,"cm"))) +theme_bw()+
geom_point(aes(x=32.6662,y= -117.0793),color='red', size=5)+
geom_point(aes(x=end_latitude,y=end_longitude, color=Direction) ,size=2)+
geom_label_repel(aes(x=end_latitude,y= end_longitude, label=speed1, color = Direction),
fontface = 'bold', force=10,
box.padding = unit(0.25, "lines"),
point.padding = unit(0.5, "lines"))+
scale_colour_manual(values=cbPalette)+
annotate("text", x=32.67,y= -117.075, label = "Crash on Northbound",
size=6, colour='red')+
geom_segment(aes(x=32.67,y= -117.076, xend = 32.6661, yend = -117.07912),
colour='red', size=0.5,arrow = arrow(length = unit(0.5, "cm")))+labs(x="Latitude", y="Longitude")
ggplot(tmc) + geom_segment(aes(color=Direction, x=miles,
xend=miles1, y=Direction, yend=Direction), size=1.5,
arrow=arrow(length=unit(0.4,"cm"))) +theme_bw()+
geom_point(aes(x=miles1,y=Direction, color=Direction) ,size=2)+
geom_point(aes(x=2,y=Direction[1]) ,size=7, color="green")+
geom_label_repel(aes(x=miles1,y= Direction, label=speed1, color = Direction),
fontface = 'bold', force=60,
box.padding = unit(0.25, "lines"),
point.padding = unit(0.5, "lines"))+
scale_colour_manual(values=cbPalette)+
geom_vline(xintercept = 2, color="red", linetype = "longdash", size=1.5)+
annotate("text", label = "Crash time: 08:11:45 AM", x = 2.05, y=1.5, size = 4, colour = "red", angle=90)+
geom_segment(aes(x=1.6,y= 0.8, xend = 2, yend = 1),
colour='red', size=0.5,arrow = arrow(length = unit(0.5, "cm")))+
annotate("text", x=1.5,y= 0.75, label = "Crash on Northbound",
size=4, colour='red')
by Subasish Das