Ejemplo n.º 1
0
def draw_rexburg_map(corners=CORNERS,
                     zoom_start=13,
                     border=True,
                     grid=True,
                     grid_size=1,
                     grid_numbers=False,
                     circles=False,
                     grid_radius=None):

    rexburg_map = folium.Map(location=MAP_CENTER, zoom_start=zoom_start)

    if grid_radius is None:
        grid_radius = calc_grid_radius(grid_size)

    if grid_numbers or grid:
        grid_squares = grid_square_bounds(grid_size)

    if grid_numbers or circles:
        grid_centers = calc_grid_centers(grid_size)

    if border:
        folium.Rectangle([each for each in corners[::2]],
                         color='gray',
                         weight=2).add_to(rexburg_map)

    if grid:
        for row in grid_squares:
            for square in row:
                folium.Rectangle(square, fill=False, weight=0.5,
                                 color='gray').add_to(rexburg_map)

    if grid_numbers:
        counter = 1
        for row in grid_squares:
            for square in row:
                folium.map.Marker(
                    [
                        grid_centers[counter - 1][0],
                        grid_centers[counter - 1][1]
                    ],
                    icon=DivIcon(
                        icon_size=(1, 1),
                        icon_anchor=(5, 5),
                        html=f'<div style="text-align:center;font-size:6pt"'
                        f'>{counter}</div>')).add_to(rexburg_map)

                counter += 1

    if circles:
        for lat, long in grid_centers:
            folium.Circle([lat, long],
                          radius=grid_radius,
                          fill=True,
                          fill_opacity=0.2,
                          weight=0.3).add_to(rexburg_map)

    return rexburg_map
Ejemplo n.º 2
0
def render_map(bounds, detection_df):

    receiver_info = detection_df[[
        'Receiver.lat', 'Receiver.lon', 'Receiver.ID', 'Receiver',
        'Receiver.depth'
    ]].drop_duplicates()
    receiver_locations_df = detection_df[['Receiver.lat',
                                          'Receiver.lon']].drop_duplicates()
    receiver_locations = list(
        zip(receiver_locations_df['Receiver.lat'],
            receiver_locations_df['Receiver.lon']))
    center = ((bounds['north'] + bounds['south']) / 2,
              (bounds['east'] + bounds['west']) / 2)

    m = folium.Map(location=center, zoom_start=8)
    folium.Rectangle(bounds=((bounds['north'], bounds['east']),
                             (bounds['south'], bounds['west'])),
                     color='#ff7800',
                     fill=True,
                     fill_color='#ffff00',
                     fill_opacity=0.1).add_to(m)
    tooltip = "Test"
    for lat, lon in receiver_locations:
        folium.Marker([lat, lon], popup="Sample Marker",
                      tooltip=tooltip).add_to(m)

    return m
 def draw_map(self, real_bounds, pred_circles, pred_back_circles,
              other_shops_bounds):
     for other_bound in real_bounds:
         folium.Rectangle(bounds=other_bound,
                          color='#ff0000',
                          fill=True,
                          fill_color='#ff0000',
                          fill_opacity=0.2).add_to(self.visual_map)
     for pred_circle in pred_circles:
         folium.Circle(
             location=pred_circle,
             # radius=self.args.circle_size,
             radius=250,
             color='#004080',
             fill=True,
             fill_color='#004080',
             fill_opacity=0.2).add_to(self.visual_map)
     for pred_circle in pred_back_circles:
         folium.Circle(
             location=pred_circle,
             # radius=self.args.circle_size,
             radius=250,
             color='#FFFF00',
             fill=True,
             fill_color='#FFFF00',
             fill_opacity=0.2).add_to(self.visual_map)
     for other_bound in other_shops_bounds:
         folium.Polygon(locations=other_bound,
                        color='#00FF00',
                        fill=True,
                        fill_color='#00FF00',
                        fill_opacity=0.2).add_to(self.visual_map)
     self.visual_map.save("mp_trick_feature_removed.html")
def create_folium_map(dataframe: pd.DataFrame, lat_lon_range: list,
                      points_considered: int):
    """
    Create a folium interactive map for some random sampled tweets posted in one city
    :param dataframe: a tweet dataframe
    :param lat_lon_range: a latitude and longitude range
    :param points_considered: the number tweets plotted on the map
    :return: a folium map containing the random sampled tweets posted in one city
    """
    created_map = folium.Map(
        location=[dataframe['lat'].mean(), dataframe['lon'].mean()],
        zoom_start=8)
    dataframe['pos'] = dataframe.apply(lambda row: (row['lat'], row['lon']),
                                       axis=1)
    if dataframe.shape[0] > points_considered:  # Check the dataframe size
        dataframe_sampled = dataframe.sample(points_considered)
    else:
        dataframe_sampled = dataframe.copy()
    # Draw the tweets on the interactive map
    for index, row in dataframe_sampled.iterrows():
        created_map.add_child(
            folium.CircleMarker(location=(row['pos'][0], row['pos'][1]),
                                radius=1,
                                color='black',
                                alpha=0.3))
    # Draw the pre-defined bounding box
    created_map.add_child(
        folium.Rectangle(bounds=[[[lat_lon_range[1], lat_lon_range[0]],
                                  [lat_lon_range[3], lat_lon_range[2]]]]))
    created_map.add_child(
        folium.Marker(location=[lat_lon_range[1], lat_lon_range[0]]))
    created_map.add_child(
        folium.Marker(location=[lat_lon_range[3], lat_lon_range[2]]))
    return created_map
Ejemplo n.º 5
0
    def draw_preview(self, bounds):

        # todo: handle projection error

        x1, y1, x2, y2 = bounds
        map_preview = folium.Map()
        map_preview.fit_bounds([[y1, x1], [y2, x2]])
        folium.Rectangle(bounds=[[y1, x1], [y2, x2]],
                         fill_color='#31708f',
                         fill_opacity=0.2,
                         weight=1,
                         color='#31708f').add_to(map_preview)

        html_map = map_preview.get_root().render()
        html_b64 = base64.b64encode(html_map.encode('utf-8'))
        #self.html_map_preview = ipyw.HTML('<iframe src="data:text/html;charset=utf-8;base64,' + html_b64 + '" width=480 height=300></iframe>')
        display(
            Javascript('''
            $(function(){
                var map_preview = document.getElementById("iframpe_map_preview");
                if(map_preview != null)
                    map_preview.src = "data:text/html;charset=utf-8;base64, %s";
            });
        ''' % (html_b64.decode())))
        self.form_map_preview.layout.display = 'inline'
Ejemplo n.º 6
0
def plotSumsonMap():

    m = folium.Map([51.4545, -2.58], zoom_start=13)
    n_bins = 100
    (lat_min, lat_max) = (51.427563, 51.481476)
    (lng_min, lng_max) = (-2.631043, -2.544795)

    lat_range = np.linspace(lat_min, lat_max, n_bins)
    lng_range = np.linspace(lng_min, lng_max, n_bins)

    lat_res = (lat_range[1] - lat_range[0]) / 2
    lng_res = (lng_range[1] - lng_range[0]) / 2

    data = loadmat('Data/latlngthetasum.mat')
    lltss = data['llts']
    #lltss = lltss[:200]
    Sums = [Sum for Lat, Lng, Theta, Sum in lltss]
    Sum_max = max(Sums)

    bar = Bar('Plotting Tiles', max=len(Sums))
    for llts in lltss:
        Lat, Lng, Theta, Sum = llts
        bounds = [[Lat + lat_res, Lng - lng_res],
                  [Lat - lat_res, Lng + lng_res]]
        opacity = Sum / Sum_max
        folium.Rectangle(bounds,
                         color='#0000ff',
                         fill='#0000ff',
                         opacity=opacity,
                         fill_opacity=opacity,
                         tooltip=str((Sum))).add_to(m)
        bar.next()
    bar.finish()
    m.save('Maps/TotalDepartures.html')
Ejemplo n.º 7
0
def plotDifferenecesonMap():

    m = folium.Map([51.4545, -2.58], zoom_start=13)
    n_bins = 100
    (lat_min, lat_max) = (51.427563, 51.481476)
    (lng_min, lng_max) = (-2.631043, -2.544795)

    lat_range = np.linspace(lat_min, lat_max, n_bins)
    lng_range = np.linspace(lng_min, lng_max, n_bins)

    lat_res = (lat_range[1] - lat_range[0]) / 2
    lng_res = (lng_range[1] - lng_range[0]) / 2

    data = loadmat('Data/latlngdiff.mat')
    llds = data['lld']
    #llds = llds[:1000]
    Diffs = [Diff for Lat, Lng, Diff in llds]
    Diff_max = max(Diffs)
    Diff_min = min(Diffs)

    bar = Bar('Plotting Tiles', max=len(Diffs))
    for lld in llds:
        Lat, Lng, Diff = lld
        #print(Lat, Lng, Diff)
        bounds = [[Lat + lat_res, Lng - lng_res],
                  [Lat - lat_res, Lng + lng_res]]
        opacity = Diff / 51.428652
        if opacity > 0:
            folium.Rectangle(bounds,
                             color='#00ff00',
                             fill='#00ff00',
                             opacity=Diff / 51.428652,
                             fill_opacity=Diff / 51.428652,
                             tooltip=str((Diff))).add_to(m)
        else:
            folium.Rectangle(bounds,
                             color='#ff0000',
                             fill='#ff0000',
                             opacity=abs(Diff / 51.428652),
                             fill_opacity=abs(Diff / 51.428652),
                             tooltip=str((Diff))).add_to(m)

        bar.next()
    bar.finish()
    m.save('Maps/Differences.html')
Ejemplo n.º 8
0
    def add_cell_object(self, bounds, tooltips):
        '''
        returns folium.rectangle with bounds = bounds and tooltip(s) = tooltips
        :param: bounds = cell_bounds 4 lat lon coords [ [lat, lon] [lat, lon] [lat, lon] [lat, lon] ]
        :param: tooltip: dict of k,v pairs where key = context and v = tooltip value
        ie., {'Average Speed in Cell': row['avg_speed']}

        populates cell_df with folium rectangle objects
        '''
        tips = ''
        for k, v in tooltips.items():
            tips += f'{k}: {v}\n'
        return folium.Rectangle(bounds=bounds, tooltip=tips)
Ejemplo n.º 9
0
def plot_areas(data):
	import folium
	nlMap = folium.Map(location=[52.228175,5.3473425], tiles='Stamen Toner', zoom_start=6)
	points = []
	for area in data:
		points.append(area[0][0])
		points.append(area[0][1])
		col='white'
		if area[1]>66:
			col='red'
		elif area[1]>33:
			col = "yellow"
		else:
			col = "green"
		folium.Rectangle(points,color=col,opacity=1,fill=True).add_to(nlMap)
		points=[]
	nlMap.save('laPointMap.html')
Ejemplo n.º 10
0
 def plotTemp(self, mapObj, color=(0.0, 1.0, 1.0)):
     tempGrid = np.ndarray(self.shape)
     for i in range(self.shape[0]):
         for j in range(self.shape[1]):
             tempGrid[i,j] = self.grid[i,j].temp
     tempGrid = np.nan_to_num(tempGrid) #replace nans with 0                
     tempGrid = tempGrid / np.max(tempGrid)
     colorRGB = colorsys.hsv_to_rgb(color[0], color[1], color[2])
     colorHex = matplotlib.colors.to_hex(colorRGB)
     for i in range(self.shape[0]):
         for j in range(self.shape[1]):
             cell = self.grid[i,j]
             opacity = tempGrid[i,j]
             folium.Rectangle(
                 bounds=cell.points,
                 fill_color=colorHex,
                 fill=True,
                 fill_opacity=opacity
                 ).add_to(mapObj)
     mapObj.save('tempMap.html')
Ejemplo n.º 11
0
def plot_areas_map(areas):
	import folium	
	nlMap = folium.Map(location=[52.228175,5.3473425], tiles='Stamen Toner', zoom_start=6)
	points = []
	for area in areas:
		area = [float(x) for x in area]
		p=[[area[0],area[1]],[area[2],area[3]]]
		points.append(p[0])
		points.append(p[1])
		col='white'	
		if area[-1]>66:
			col='red'
		elif area[-1]>33:
			col = "yellow"
		else:
			col = "green"
		folium.Rectangle(points,color=col,opacity=1,fill=True).add_to(nlMap)
		points=[]

	nlMap.save('map.html')
	print('open map.html')
Ejemplo n.º 12
0
 def plotFish(self, species, mapObj=None, color=(0.4, 1.0, 1.0)):
     fishGrid = np.ndarray(self.shape)
     for i in range(self.shape[0]):
         for j in range(self.shape[1]):
             if species.lower() == 'herring':
                 fishGrid[i,j] = self.grid[i,j].herring
             elif species.lower() == 'mackerel':
                 fishGrid[i,j] = self.grid[i,j].mackerel
     fishGrid = fishGrid / np.max(fishGrid)  #scale between 0 and 1
     if mapObj == None:
         plt.imshow(fishGrid)
         plt.show()
     else:
         threshold = 0.05 #scale values 0 to 0.10 between 0 and 1.0 opacity, set greater values to 1.0
         colorRGB = colorsys.hsv_to_rgb(color[0], color[1], color[2])
         colorHex = matplotlib.colors.to_hex(colorRGB)
         for i in range(self.shape[0]):
             for j in range(self.shape[1]):
                 cell = self.grid[i,j]
                 opacity = fishGrid[i,j] / threshold
                 if opacity > 1.0:
                     opacity = 1.0
                 folium.Rectangle(
                     bounds=cell.points,
                     fill_color=colorHex,
                     fill=True,
                     fill_opacity=opacity
                     ).add_to(mapObj)
                 if cell.fishery:
                     folium.Circle(
                         location=cell.center,
                         radius=1000,
                         color='lightblue',
                         fill=True,
                         fill_opacity=0.7
                         ).add_to(mapObj)
Ejemplo n.º 13
0
start_point = get_latlo(startingpoint)
st.sidebar.text(start_point)
endingpoint = st.sidebar.text_input("Where do you want to go?", "Chrysler building")
end_point = get_latlo(endingpoint)
st.sidebar.text(end_point)
pax_count =  st.sidebar.slider("How many passengers?",1,8, 2)
time_var = st.sidebar.time_input("When do you want to take a taxi?", value=datetime.datetime(2021, 10, 6, 12, 10, 20))

data = pd.DataFrame({
    'awesome cities' : ["Start", "End"],
    'lat' : [start_point[0], end_point[0]],
    'lon' : [start_point[1], end_point[1]]
})
points = [(40, -72.9),(40, -74.3),(42, -72.9),(42, -74.3)]
m = folium.Map(location=[NYC_center_lat, NYC_center_lon], zoom_start=9, tiles="Stamen Toner")
folium.Rectangle(bounds=points, color='#5dbb63', fill=True, fill_color='5dbb63', fill_opacity=0.1).add_to(m)
Start_pin = "Pickup Location"
folium.Marker([data.lat[0], data.lon[0]], popup="Pickup Location", tooltip=Start_pin).add_to(m)
End_pin = "Dropoff Location"
folium.Marker([data.lat[1], data.lon[1]], popup="Dropoff Location", tooltip=End_pin).add_to(m)
folium_static(m)

key = '2012-10-06 12:10:20.0000001'
pickup_date = st.sidebar.date_input('pickup datetime', value=datetime.datetime(2021, 10, 6, 12, 10, 20))
pickup_datetime = f'{pickup_date} {time_var}UTC'
pickup_longitude = start_point[1]
pickup_latitude = start_point[0]
dropoff_longitude = end_point[1]
dropoff_latitude = end_point[0]
passenger_count = pax_count
Ejemplo n.º 14
0
              popup='<strong>Location Three</strong>',
              tooltip=tooltip,
              icon=folium.Icon(color='purple')).add_to(m)

folium.Marker(l4,
              popup='<strong>Location Four</strong>',
              tooltip=tooltip,
              icon=folium.Icon(color='green', icon='leaf')).add_to(m)

folium.Marker(l5,
              popup='<strong>Indeed Austin Tech Campus</strong>',
              tooltip=tooltip,
              icon=logoIcon).add_to(m)

# Rectangle Marker
DT_bounds = [[30.274182, -97.735996], [30.269182, -97.755996]]
folium.Rectangle(DT_bounds,
                 color="#ff7800",
                 weight=1,
                 fill=True,
                 fill_color='#ff7800').add_to(m)

# Geojson overlay
overlay = os.path.join('data', 'overlay.json')
folium.GeoJson(
    overlay,
    name='UT Austin',
).add_to(m)

# Generate map
m.save("map.html")
Ejemplo n.º 15
0
myColors = [
    'black', 'red', 'green', 'blue', 'yellow', 'brown,', 'purple', 'pink',
    'white'
]

clusterMap = folium.Map([-19.92364, -43.94951], zoom_start=13)

for index, cell in grid.iterrows():
    startLat = cell['startLat']
    startLon = cell['startLon']
    endLat = cell['endLat']
    endLon = cell['endLon']
    idx = cell['cluster']
    folium.Rectangle([[startLat, startLon], [endLat, endLon]],
                     popup=str(index),
                     color=myColors[int(cell['cluster'])],
                     fill=True).add_to(clusterMap)

clusterMap.save('../client/public/results/cluster.html')

# In[35]:

signatureData = {}
for clusterId in grid['cluster'].unique():
    signatureData[clusterId] = []
    for idx, row in grid[grid['cluster'] == clusterId].iterrows():
        signatureData[clusterId].append(signature[idx])

# In[61]:

myPlotData = []
Ejemplo n.º 16
0
            new_line = lines[i]
            parsed = re.split('\s+', new_line.rstrip())
            bus_id = int(parsed[0])
            load_shed = float(parsed[1])
            bus_shed[bus_id] = load_shed
            i += 1
    i += 1

print(branches)
for branch in branches:
    f_bus = branch[0]
    t_bus = branch[1]
    dx = 0.35
    folium.Rectangle(
        bounds=[[position[f_bus][0] - dx, position[f_bus][1] + dx],
                [position[f_bus][0] + dx, position[f_bus][1] - dx]],
        line_join='bevel',
        color='red').add_to(m)
    folium.Rectangle(
        bounds=[[position[t_bus][0] - dx, position[t_bus][1] + dx],
                [position[t_bus][0] + dx, position[t_bus][1] - dx]],
        line_join='bevel',
        color='red').add_to(m)
    value = [list(position[f_bus]), list(position[t_bus])]
    folium.PolyLine(value, color='red', weight=3).add_to(m)

total_shed = sum(bus_shed.values())
for (bus_id, value) in bus_shed.items():
    folium.CircleMarker(location=list(position[bus_id]),
                        radius=value / total_shed * 100,
                        color='black',
    color="crimson",
    fill=False,
).add_to(map)

folium.CircleMarker(
    location=[47.0, 39.1],
    radius=50,
    popup="Laurelhurst Park",
    color="#3186cc",
    fill=True,
    fill_color="#3186cc",
).add_to(map)

folium.PolyLine([[47.03, 39.01], [47.06, 39.01], [47.06, 39.1]]).add_to(map)

folium.Rectangle([[47.0, 39.0], [47.1, 39.3]]).add_to(map)

# Fit the map to contain a bounding box with the maximum zoom level possible.
map.fit_bounds([[47.0, 39.0], [47.1, 39.3]])

#for point in range(0, len(locationlist)):
#    folium.Marker(locationlist[point], popup=df_counters['Name'][point]).add_to(map)
map.save("1111.htm")

#import io
#from PIL import Image

#img_data = map._to_png(10)
#img = Image.open(io.BytesIO(img_data))
#img.save('image.png')
Ejemplo n.º 18
0
    starts.write("\n")
    starts.write(str(updateOriginTime))
    starts.write('\n')
    starts.write(capid)

print("The program has started. Most recent event ID: " + str(detectionID) + ". Origin on: " + str(updateOriginTime) + ". Awaiting quake...")

#   Get initial check on the RunLog

rls = os.stat(curdir + "/RunLog.txt")[8]


#   Base map
ma = folium.Map(tiles = "Stamen Terrain")
ma.fit_bounds([(46,-131.75),(52.2,-123)])
folium.Rectangle([(46,-131.75),(52.2,-123)], popup = folium.Popup("WARN Detection Boundary")).add_to(ma)

while True:
    #   Check if the RunLog file is changed
    rlc = os.stat(curdir + "/RunLog.txt")[8]

    
    if rlc != rls:
        #   Update rls
        rls = rlc
        
        time.sleep(1)
        
        #   Parse WARN API Payload XML
        with open(curdir + "/RunLog.txt", 'r') as wl:
            warn_payload = wl.read()
Ejemplo n.º 19
0
    def generate_maps(self):
        '''
        Generates 3 folium map objects with city bounds and cells overlaid on each.
        Maps stored as instance varible. 
        '''
        print('Generating maps...')
        width, height = 960, 600
        ne, sw = self.mdl.get_yyc_bounds()

        cells = self.get_frame('cells')

        cells['cells'] = cells.apply(lambda row: self.add_cell_object(
            row['cell_bounds'], {
                'Cell': row.name,
                'Average Speed': row['avg_speed'],
                'Total Volume': row['volume_sum'],
                'Total Incidents': row['incident_count'],
                'Sign count': row['sign_count'],
                'Signal count': row['signal_count']
            }),
                                     axis=1)
        cells['vol_cells'] = cells.apply(
            lambda row: self.add_cell_object(row['cell_bounds'], {
                'Cell': row.name,
                'Total Volume': row['volume_sum']
            }),
            axis=1)

        cells['speed_cells'] = cells.apply(
            lambda row: self.add_cell_object(row['cell_bounds'], {
                'Cell': row.name,
                'Average Speed': row['avg_speed']
            }),
            axis=1)

        # NOTE: Deep copy of maps is not possible
        # https://github.com/python-visualization/folium/issues/1207

        # NOTE: We must duplicate the folium objects to add to each map:
        # https://stackoverflow.com/questions/25293579/multiple-leaflet-maps-on-same-page-with-same-options

        self.cell_map = folium.Map(location=[51.0478, -114.0593],
                                   width=width,
                                   height=height,
                                   toFront=True)
        self.speed_map = folium.Map(location=[51.0478, -114.0593],
                                    width=width,
                                    height=height,
                                    toFront=True)
        self.volume_map = folium.Map(location=[51.0478, -114.0593],
                                     width=width,
                                     height=height,
                                     toFront=True)

        for cell in self.get_frame('cells')['cells']:
            cell.add_to(self.cell_map)

        for cell in self.get_frame('cells')['vol_cells']:
            cell.add_to(self.volume_map)

        for cell in self.get_frame('cells')['speed_cells']:
            cell.add_to(self.speed_map)

        rect1 = folium.Rectangle(bounds=[ne, sw],
                                 weight=2,
                                 dash_array=("4"),
                                 color='red',
                                 tooltip='Analysis Boundary')

        rect2 = folium.Rectangle(bounds=[ne, sw],
                                 weight=2,
                                 dash_array=("4"),
                                 color='red',
                                 tooltip='Analysis Boundary')

        rect3 = folium.Rectangle(bounds=[ne, sw],
                                 weight=2,
                                 dash_array=("4"),
                                 color='red',
                                 tooltip='Analysis Boundary')

        rect1.add_to(self.cell_map)
        rect2.add_to(self.speed_map)
        rect3.add_to(self.volume_map)

        self.cell_map.save('./html/cell_map.html')
        self.speed_map.save('./html/speed_map.html')
        self.volume_map.save('./html/volume_map.html')

        # Drop extra folium vector object series once we are done adding to maps
        cells = self.get_frame('cells')
        cells = cells.drop(['vol_cells', 'speed_cells'], axis='columns')

        print('...maps generated.')
Ejemplo n.º 20
0
def main(args):
    parser = argparse.ArgumentParser("")
    parser.add_argument('-d', '--date')
    parser.add_argument('-s', '--station')

    try:
        global opt
        opt = parser.parse_args(args[1:])
    except:
        parser.print_help()
        raise

    option = webdriver.ChromeOptions()
    option.add_argument("headless")
    driver = webdriver.Chrome(ChromeDriverManager().install(), options=option)
    driver.set_window_size(1300, 1400)

    gdf_line = geopandas.read_file("mrt_line.geojson")
    gdf_node = geopandas.read_file("mrt_station.geojson")
    icon_url = "https://i.imgur.com/GZy08h3.png"

    for i in range(24):
        line_dict = json.load(
            open('{}_{}.json'.format(i, opt.date), encoding='utf-8-sig'))
        m = folium.Map(location=[25.061, 121.515],
                       zoom_start=13,
                       tiles="CartoDB positron",
                       zoom_control=False)
        for idx, row in gdf_line.iterrows():
            # MultiLineString to list
            # https://gis.stackexchange.com/questions/319295/how-to-reverse-the-multilinestring-command-to-a-list-of-arrays
            loc = [list(x.coords) for x in list(row.geometry)][0]
            loc = [tuple(reversed(x)) for x in loc]

            weight = line_dict[row["name"]] * 2000
            color = Line_Color(row["Line_No"])
            folium.PolyLine(loc, color=color, weight=weight,
                            opacity=1).add_to(m)

        for idx, row in gdf_node.iterrows():
            if row["中文站名"] in [
                    "中山", "台北車站", "大安", "板橋", "古亭", "西湖", "西門", "中正紀念堂", "士林",
                    "忠孝新生", "忠孝復興", "淡水", "北投", "蘆洲", "新莊", "三重", "江子翠",
                    "永安市場", "南港", "景美"
            ]:
                loc = list(reversed(list(row["geometry"].coords)[0]))
                icon = folium.features.CustomIcon(icon_url, icon_size=(16, 16))
                folium.Marker(loc, icon=icon).add_to(m)

        p0 = [25.163, 121.5945]
        p1 = [25.15, 121.59]
        p2 = [25.165, 121.62]
        folium.Marker(
            p0,
            icon=folium.DivIcon(
                html=
                '<div style="font-size: 40pt; color : black">{:02d}:00</div>'.
                format(i))).add_to(m)
        folium.Rectangle([p1, p2],
                         color='#ff7800',
                         fill=True,
                         fill_color='#ffff00',
                         fill_opacity=0.2).add_to(m)

        m.save("{}_{}.html".format(i, opt.date))

        url = "file:///Users/sam/{}_{}.html".format(i, opt.date)
        driver.get(url)
        driver.get_screenshot_as_file("{}_{}.png".format(i, opt.date))
Ejemplo n.º 21
0
 def _draw_rectangle_of_rehovot(mymap):
     rehovot_bounds_bltr = [[31.86704, 34.77173], [31.91921, 34.83712]] #[[bottom(lat min), left(long min)], [top(lat max), right(long max)]]
     folium.Rectangle(bounds=rehovot_bounds_bltr, color='#ff7800', fill=True, fill_color='#ffff00', fill_opacity=0.2).add_to(mymap)
     return mymap