0

I am struggling to combine colour coding to a Z variable (ShipSpeedGPS.Knots.) in a Y Variable (Lon) and X Var (Lat) plot.

I have mapped the route via the following commands

NWSMAP = qmap('brunei', zoom=3)

NWSMAP + geom_point(aes(x=Lon, y=Lat), data=D3)

And separately I have been able colour code the route without the base map by the following commands

D3Plot = ggplot(data = D3, aes(x=Lat, y=Lon, colour=yval))

D3Plot + geom_point(aes(colour = D3$ShipSpeedGPS.Knots.))

Ideally I would like to combine both of these features into the one chart. The 'brunei' map base with the route colour coded based on the speed of the vessel. This is so I can visually show the captains of the vessels where they are going unnecessarily fast and are 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
zx8754
  • 52,746
  • 12
  • 114
  • 209
  • 1
    If the variable name is "ShipSpeed" then you cannot get any useful information from indexing d3 with `D3$ShipSpeedGPS.Knots.`. R does not allow operations just by postfixing a name. You need to present `str(D3)` and describe in greater detail what you expect. – IRTFM Jul 15 '15 at 06:34

1 Answers1

0

Figured the 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))