Leaflet colours for polylines

前端 未结 2 1742
悲&欢浪女
悲&欢浪女 2020-12-18 12:30

I would like to use a basic data.frame to get three polylines each of different colours

I am currently using the below code as an example.

require(le         


        
2条回答
  •  离开以前
    2020-12-18 12:38

    Here is a way to automate for each group in your dataset:

    map <-  leaflet(df)
    map <- addTiles(map)
    for( group in levels(df$group)){
            map <- addPolylines(map, lng=~lon,lat=~lat,data=df[df$group==group,], color=~col)
            }
    map
    

提交回复
热议问题