i struggling combine colour coding z variable (shipspeedgps.knots.) in y variable (lon) , x var (lat) plot.
i have mapped route via following commands
nwsmap = qmap('brunei', zoom=3) nwsmap + geom_point(aes(x=lon, y=lat), data=d3) and separately have been able colour code route without base map following commands
d3plot = ggplot(data = d3, aes(x=lat, y=lon, colour=yval)) d3plot + geom_point(aes(colour = d3$shipspeedgps.knots.)) ideally combine both of these features 1 chart. 'brunei' map base route colour coded based on speed of vessel. can visually show captains of vessels going unnecessarily fast , wasting fuel.
str(d3) 'data.frame': 74843 obs. of 15 variables: $ date : date, format: "2015-04-27" $ time : factor w/ 86401 levels "","0:00:00" $ lat : num -19.9 $ lon : num 117 $ shipcourse.deg. : int 182 $ shipspeedgps.knots. : num 13.4 $ shipspeedlog.knots. : num 13.6 $ shipspeedpropllr.knots.: num 14.3 $ wind.dir..rel...deg. : int 0 $ wind.speed.abs...knots.: num 13.3 $ windspeedrel...knots. : num 0 $ shaftpower.kw. : int 7526 $ shaftspeed.rpm. : num 58.8 $ shafttorque.knm. : int 1222 $ shaftthrust..kn. : int 915
figured solution
nwsmap2 = get_map(location = "brunei", zoom = 3) ggmap(nwsmap2) + geom_point(data = d3, aes(x = lon, y = lat, color = shipspeedgps.knots.)) + scale_colour_gradient(low="green", high="red", limits=c(10,16))
Comments
Post a Comment