How to use the folium.PolyLine function in folium

To help you get started, we’ve selected a few folium examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python-visualization / folium / tests / plugins / test_polyline_text_path.py View on Github external
[47.754100, -43.94531],
                      [38.272690, -37.96875],
                      [27.059130, -41.13281],
                      [16.299050, -36.56250],
                      [8.4071700, -30.23437],
                      [1.0546300, -22.50000],
                      [-8.754790, -18.28125],
                      [-21.61658, -20.03906],
                      [-31.35364, -24.25781],
                      [-39.90974, -30.93750],
                      [-43.83453, -41.13281],
                      [-47.75410, -49.92187],
                      [-50.95843, -54.14062],
                      [-55.97380, -56.60156]]

    wind_line = folium.PolyLine(wind_locations, weight=15, color='#8EE9FF')
    attr = {'fill': '#007DEF', 'font-weight': 'bold', 'font-size': '24'}
    wind_textpath = plugins.PolyLineTextPath(wind_line,
                                             ') ',
                                             repeat=True,
                                             offset=7,
                                             attributes=attr)

    m.add_child(wind_line)
    m.add_child(wind_textpath)

    out = normalize(m._parent.render())

    # We verify that the script import is present.
    script = ''  # noqa
    assert script in out
github SanPen / GridCal / src / GridCal / Engine / Visualization / visualization.py View on Github external
# compose the tooltip
            tooltip = str(i) + ': ' + branch.name
            tooltip += '\n' + loading_label + ': ' + "{:10.4f}".format(lnorm[i] * 100) + ' [%]'
            if s_branch is not None:
                tooltip += '\nPower: ' + "{:10.4f}".format(s_branch[i]) + ' [MVA]'
            if losses is not None:
                tooltip += '\nLosses: ' + "{:10.4f}".format(losses[i]) + ' [MVA]'

            # get the line colour
            r, g, b, a = loading_cmap(lnorm[i])
            color = QtGui.QColor(r * 255, g * 255, b * 255, a * 255)
            html_color = color.name()
            weight = 3

            # draw the line
            folium.PolyLine(points,
                            color=html_color,
                            weight=weight,
                            opacity=1,
                            tooltip=tooltip).add_to(marker_cluster)

    # save the map
    my_map.save(file_name)

    print('Map saved to:\n' + file_name)
github azavea / bus-plan / analysis / map_solver.py View on Github external
def a(df, line_name, pal, m):

            def c(df, line_name):
                line = df[df.route_id == line_name]
                stops = line[line.stop_sequence == 0].append(line[-1:])
                coords = [[row[1]['y'], row[1]['x']] for row in line.iterrows()]
                stops = [[row[1]['y'], row[1]['x']] for row in stops.iterrows()]
                return coords, stops

            coords, stops = c(df, line_name)
            color = pal[line_name]
            fg = folium.FeatureGroup(name='Route ' + str(line_name))
            fg.add_child(folium.PolyLine(coords, weight=3, opacity=0.75, color=color))
            for point in stops:
                if point == stops[0]:
                    fc = [4, '#006600']
                elif point == stops[-2]:
                    fc = [4, '#CC0000']
                else:
                    fc = [2, '#FFFFFF']
                cm = folium.CircleMarker(
                    point, color=color, fill=True,
                    fill_color=fc[1], fill_opacity=1, radius=fc[0])
                fg.add_child(cm)
            m.add_child(fg)
github python-visualization / folium / examples / polyline_text_path_example.py View on Github external
[47.754100, -43.94531],
                  [38.272690, -37.96875],
                  [27.059130, -41.13281],
                  [16.299050, -36.56250],
                  [8.4071700, -30.23437],
                  [1.0546300, -22.50000],
                  [-8.754790, -18.28125],
                  [-21.61658, -20.03906],
                  [-31.35364, -24.25781],
                  [-39.90974, -30.93750],
                  [-43.83453, -41.13281],
                  [-47.75410, -49.92187],
                  [-50.95843, -54.14062],
                  [-55.97380, -56.60156]]

wind_line = folium.PolyLine(wind_locations,
                            weight=15,
                            color='#8EE9FF').add_to(m)
attr = {'fill': '#007DEF', 'font-weight': 'bold', 'font-size': '24'}
plugins.PolyLineTextPath(wind_line,
                         ") ",
                         repeat=True,
                         offset=7,
                         attributes=attr).add_to(m)

danger_line = folium.PolyLine([[-40.311, -31.952],
                               [-12.086, -18.727]],
                              weight=10,
                              color='orange',
                              opacity=0.8).add_to(m)
attr = {'fill': 'red'}
plugins.PolyLineTextPath(danger_line,
github InsightLab / PyMove / pymove / utils / trajectories.py View on Github external
>>> save_bbox(bbox, 'bbox.html')

    """

    m = folium.Map(tiles=tiles)
    m.fit_bounds(
        [[bbox_tuple[0], bbox_tuple[1]], [bbox_tuple[2], bbox_tuple[3]]]
    )
    points_ = [
        (bbox_tuple[0], bbox_tuple[1]),
        (bbox_tuple[0], bbox_tuple[3]),
        (bbox_tuple[2], bbox_tuple[3]),
        (bbox_tuple[2], bbox_tuple[1]),
        (bbox_tuple[0], bbox_tuple[1]),
    ]
    folium.PolyLine(points_, weight=3, color=color).add_to(m)
    m.save(file)
    if return_map:
        return m
github FinalProject0b1100100 / tfa_project / file.py View on Github external
startpoint_ll = get_lat_lng(startpoint,api_key)
    m = folium.Map(location=startpoint_ll,zoom_start=14)
    icon_hz = dict(prefix='fa', color='red', icon_color='darkred', icon='cny')
    folium.Marker(startpoint_ll, popup = startpoint,icon=folium.Icon(color='green')).add_to(m)
    for i in range(len(df)):
            folium.Marker([df.iloc[i]['lat'],df.iloc[i]['lng']],
                            popup='Attraction: '+df.iloc[i]['attraction']+ ';   Address: '+df.iloc[i]['address']
                          + ';   Duration: ' +str(df.iloc[i]['duration'])+' hour(s);   Type: ' +df.iloc[i]['type']
                          + ';   Link: ' +df.iloc[i]['attraction_link']
                             ).add_to(m)
    for i in route_edges:
        lat1 = df2[df2['attraction']==i[0]]['lat'].iloc[0]
        lng1 = df2[df2['attraction']==i[0]]['lng'].iloc[0]
        lat2 = df2[df2['attraction']==i[1]]['lat'].iloc[0]
        lng2 = df2[df2['attraction']==i[1]]['lng'].iloc[0]
        ls = folium.PolyLine(locations=[[lat1,lng1],[lat2,lng2]],color='blue')
        ls.add_to(m)
    return m
# get_map(startpoint,df2)
github perimosocordiae / route-plotter / route_map.py View on Github external
loc = np.mean([r.start_coord() for r in routes], axis=0).tolist()
  run_map = folium.Map(location=loc, tiles=args.tileset, zoom_start=14)

  coords = [r.coords for r in routes]
  if args.color_by == 'none':
    lines = folium.PolyLine(coords, color='red', opacity=0.6)
    run_map.add_child(lines)
  else:
    meta_fn = METADATA_FNS[args.color_by]
    meta = np.array([meta_fn(route) for route in routes])
    # TODO: make the colors/labels work for simple numeric metas
    hex_colors = color_mapping(meta.astype(int), args.line_colormap)
    color_labels = meta.astype(str)
    for traj, c, label in zip(coords, hex_colors, color_labels):
      line = folium.PolyLine(traj, color=c, popup=label)
      run_map.add_child(line)

  # save the map to the output html file
  run_map.save(args.output, close_file=True)

  # reduce file size and optionally add a css tweak to make the map grayscale
  dont_add_css = bool(args.color_tiles)
  for line in fileinput.input(args.output, inplace=True):
    line = line.strip()
    if not line:
      continue
    if dont_add_css or line != '':
      print(line)
    else:
      print(GRAY_CSS, line)
      dont_add_css = True