[R-sig-Geo] Adding colour to polylines in Leaflet
Kent Johnson
kent3737 @ending from gm@il@com
Sat Sep 1 14:47:53 CEST 2018
>
> Message: 5
> Date: Sat, 1 Sep 2018 08:28:24 +0530
> From: Dhiraj Khanna <dhirajkhanna using gmail.com>
> To: r-sig-geo using r-project.org
> Subject: [R-sig-Geo] Adding colour to polylines in Leaflet
> Message-ID:
> <CANHhK329-Y7hPJD9gSOs24mSqGkrjC481oQspNA
> gVisAw2JBoQ using mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> I am working with shipping data where I get the dynamic parameters of a
> ship like its position, speed, heading and rate of turn. I am then trying
> to plot this on a leaflet map and trying to colour the polylines based on
> the speed, but it always shows up in the same colour. Here’s some sample
> data:
>
> <snip>
> This is the code I have tried which doesn’t work:-
>
> map <- leaflet(x) map <- addTiles(map) for( Color in
> levels(as.factor(x$Color))){ map <- addPolylines(map,
> lng=~lon,lat=~lat,data=x[x$Color==Color,], color=~Color) } map
>
> Regards
> Dhiraj Khanna
> Mob:09873263331
What are you expecting to see? When I run your code I get a map with three
lines, one red, one orange and one yellow.
Kent
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list