Flow map(Travel Path) Using Lat and Long in R

前端 未结 5 1777
臣服心动
臣服心动 2021-01-19 07:55

I am trying to plot flow map (for singapore) . I have Entry(Lat,Long) and Exit (Lat,long). I am trying to map the flow from entry to exit in singapore map.

s         


        
5条回答
  •  一向
    一向 (楼主)
    2021-01-19 08:36

    I've also written the mapdeck library to make visualisations like this more appealing*

    library(mapdeck)
    
    set_token("MAPBOX_TOKEN")  ## set your mapbox token here
    
    df$Exit_Station_Lat <- as.numeric(as.character(df$Exit_Station_Lat))
    df$Exit_Station_Long <- as.numeric(as.character(df$Exit_Station_Long))
    
    mapdeck(
      style = mapdeck_style('dark')
      , location = c(104, 1)
      , zoom = 8
      , pitch = 45
    ) %>%
      add_arc(
        data = df
        , origin = c("Entry_Station_Long", "Entry_Station_Lat")
        , destination = c("Exit_Station_Long", "Exit_Station_Lat")
        , layer_id = 'arcs'
        , stroke_from_opacity = 100
        , stroke_to_opacity = 100
        , stroke_width = 3
        , stroke_from = "#ccffff"
        , stroke_to = "#ccffff"
      )
    

    *subjectively speaking

提交回复
热议问题