当前位置: 首页>>代码示例>>Python>>正文


Python GMapPlot.select方法代码示例

本文整理汇总了Python中bokeh.models.GMapPlot.select方法的典型用法代码示例。如果您正苦于以下问题:Python GMapPlot.select方法的具体用法?Python GMapPlot.select怎么用?Python GMapPlot.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bokeh.models.GMapPlot的用法示例。


在下文中一共展示了GMapPlot.select方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Circle

# 需要导入模块: from bokeh.models import GMapPlot [as 别名]
# 或者: from bokeh.models.GMapPlot import select [as 别名]
# with gmaps

#circle = Circle(x="lon", y="lat", size=15, fill_color="blue", fill_alpha=0.8, line_color=None)
styles1 = """[{"featureType": "landscape","stylers": [{"hue": "#FFBB00"},{"saturation": 43.400000000000006},{"lightness": 37.599999999999994},{"gamma": 1}]},{"featureType": "road.highway","stylers": [{"hue": "#FFC200"},{"saturation": -61.8},{"lightness": 45.599999999999994},{"gamma": 1}]},{"featureType": "road.arterial","stylers": [{"hue": "#FF0300"},{"saturation": -100},{"lightness": 51.19999999999999},{"gamma": 1}]},{"featureType": "road.local","stylers": [{"hue": "#FF0300"},{"saturation": -100},{"lightness": 52},{"gamma": 1}]},{"featureType": "water","stylers": [{"hue": "#0078FF"},{"saturation": -13.200000000000003},{"lightness": 2.4000000000000057},{"gamma": 1}]},{"featureType": "poi","stylers": [{"hue": "#00FF6A"},{"saturation": -1.0989010989011234},{"lightness": 11.200000000000017},{"gamma": 1}]}]"""

map_options1 = GMapOptions(lat=38, lng=-79, map_type="roadmap",  zoom=7, styles=styles1)

plot = GMapPlot(title="",
#       x_axis_label='Longitude', y_axis_label='Latitude',
    plot_width=900, plot_height=500,
    x_range = Range1d(), y_range = Range1d(),
    border_fill = "#FFFFFF",
    map_options=map_options1)

plot.add_tools(PanTool(), WheelZoomTool(), BoxSelectTool(), HoverTool(),
       ResetTool(), PreviewSaveTool())

plot_glyph = plot.add_glyph(source, p)

#circle = Circle(x="lon", y="lat", size=15, fill_color="blue", fill_alpha=0.8, line_color=None)
#plot.add_glyph(source, circle)

hover = plot.select(dict(type=HoverTool))
hover.tooltips = OrderedDict([
 ("Name", "@name"),
    ("EST 2016 Population", "@pop"),
#    ("(long,lat)", "($x, $y)"),
])

#output_file("gmap_plot.html", mode='cdn')
show(plot)
开发者ID:CodeforNRV,项目名称:dss-virginia,代码行数:33,代码来源:app_skeleton.py

示例2: GMapPlot

# 需要导入模块: from bokeh.models import GMapPlot [as 别名]
# 或者: from bokeh.models.GMapPlot import select [as 别名]
    y=lad_lats,
    x=lad_longs,
    color=LAD_colors[2015],
    name=lad_names,
    uerate=lad_unemployment[2015],
    total_crime=lad_crime[2015]
))

#https://github.com/queise/Berlin_Maps/blob/master/Berlin_dens_gmap.py
p1 = GMapPlot(title="LAD", plot_width=1200, plot_height=800, x_range = Range1d(), y_range = Range1d(), map_options = GMapOptions(lat=52.6816, lng=-1.0000, zoom=7))
p1.map_options.map_type = "terrain"
patch = Patches(xs="x", ys="y", fill_color="color", fill_alpha=0.7, line_color="black", line_width=0.5)
patches_glyph = p1.add_glyph(source1, patch)
p1.add_tools(PanTool(), WheelZoomTool(), BoxSelectTool(), HoverTool(), ResetTool(), PreviewSaveTool())

hover = p1.select(dict(type=HoverTool))
hover.point_policy = "follow_mouse"
hover.tooltips = OrderedDict([
    ("Name", "@name"),
    ("Unemployment Rate","@uerate"),
    ("Crime Rate","@total_crime")
])

p2 = GMapPlot(title="LAD", plot_width=1200, plot_height=800, x_range = Range1d(), y_range = Range1d(), map_options = GMapOptions(lat=52.6816, lng=-1.0000, zoom=7))
p2.map_options.map_type = "terrain"
patch = Patches(xs="x", ys="y", fill_color="color", fill_alpha=0.7, line_color="black", line_width=0.5)
patches_glyph = p2.add_glyph(source2, patch)
p2.add_tools(PanTool(), WheelZoomTool(), BoxSelectTool(), HoverTool(), ResetTool(), PreviewSaveTool())

hover = p2.select(dict(type=HoverTool))
hover.point_policy = "follow_mouse"
开发者ID:jhotchx,项目名称:BlokesInBlue,代码行数:33,代码来源:TransformGmapUnemployment.py

示例3: main

# 需要导入模块: from bokeh.models import GMapPlot [as 别名]
# 或者: from bokeh.models.GMapPlot import select [as 别名]
def main():

    if request.method == 'GET':
        return render_template('species_MC.html')

    else:
        #request was a POST
        app.vars['species'] = request.form['selected_species']

        response = requests.get("http://api.erg.kcl.ac.uk/AirQuality/Hourly/MonitoringIndex/GroupName=London")
        root = ET.fromstring(response.content)

        info_response = requests.get("http://api.erg.kcl.ac.uk/AirQuality/Information/Species")
        info_root = ET.fromstring(info_response.content)

        latitudes = []
        longitudes =[]
        sites =[]
        AQIs = []
        AQI_colors = []

        if app.vars['species'] == 'nitrogen dioxide':

            for child in root.findall(".//*[@SpeciesCode='NO2']/..[@Latitude]"):
                x = child.get('Latitude')
                latitudes.append(x)
                x = child.get('SiteName')
                sites.append(x)
                x = child.get('Longitude')
                longitudes.append(x)
                x = child.get('BulletinDate')
                app.vars['date'] = x

            for child in root.findall(".//*[@SpeciesCode='NO2']"):
                x = child.get('AirQualityIndex')
                AQIs.append(x)

            for child in info_root.findall(".//*[@SpeciesCode='NO2']"):

                descr = child.get('Description')
                healtheffect = child.get('HealthEffect')

        elif app.vars['species'] == 'PM10 particulate matter':
            app.vars['species'] = 'PM10'

            for child in root.findall(".//*[@SpeciesCode='PM10']/..[@Latitude]"):
                x = child.get('Latitude')
                latitudes.append(x)
                x = child.get('SiteName')
                sites.append(x)
                x = child.get('Longitude')
                longitudes.append(x)
                x = child.get('BulletinDate')
                app.vars['date'] = x

            for child in root.findall(".//*[@SpeciesCode='PM10']"):
                x = child.get('AirQualityIndex')
                AQIs.append(x)

            for child in info_root.findall(".//*[@SpeciesCode='PM10']"):

                descr = child.get('Description')
                healtheffect = child.get('HealthEffect')

        elif app.vars['species'] == 'PM25 particulate matter':
            app.vars['species'] = 'PM25'

            for child in root.findall(".//*[@SpeciesCode='PM25']/..[@Latitude]"):
                x = child.get('Latitude')
                latitudes.append(x)
                x = child.get('SiteName')
                sites.append(x)
                x = child.get('Longitude')
                longitudes.append(x)
                x = child.get('BulletinDate')
                app.vars['date'] = x

            for child in root.findall(".//*[@SpeciesCode='PM25']"):
                x = child.get('AirQualityIndex')
                AQIs.append(x)

            for child in info_root.findall(".//*[@SpeciesCode='PM25']"):

                descr = child.get('Description')
                healtheffect = child.get('HealthEffect')

        elif app.vars['species'] == 'ozone':

            for child in root.findall(".//*[@SpeciesCode='O3']/..[@Latitude]"):
                x = child.get('Latitude')
                latitudes.append(x)
                x = child.get('SiteName')
                sites.append(x)
                x = child.get('Longitude')
                longitudes.append(x)
                x = child.get('BulletinDate')
                app.vars['date'] = x

            for child in root.findall(".//*[@SpeciesCode='O3']"):
                x = child.get('AirQualityIndex')
#.........这里部分代码省略.........
开发者ID:lancerane,项目名称:London_AQI,代码行数:103,代码来源:app.py

示例4: show_graph

# 需要导入模块: from bokeh.models import GMapPlot [as 别名]
# 或者: from bokeh.models.GMapPlot import select [as 别名]
def show_graph():
    df_bikes = pickle.load(open('./static/df_bikes.pickle', 'r'))
    df_stations = pickle.load(open('./static/df_stations.pickle', 'r'))
    
    # obtain the bikeid from the form
    form_data = request.form
    if form_data.get('submit'):
        try:
            bikeid = int(form_data.get('bikeid'))
        except ValueError:
            return redirect('/index')
        if bikeid not in df_bikes.index:
            return redirect('/index')
    elif form_data.get('generate'):
        bikeid = int(np.random.choice(df_bikes.index))
    
    # make plots
    n_trips = int(df_bikes.ix[bikeid].n_trips)
    n_maints = int(df_bikes.ix[bikeid].n_maints)
    n_maints_month = int(df_bikes.ix[bikeid].n_maints_month)
    n_maints_area = int(df_bikes.ix[bikeid].n_maints_area)
    month_cols = range(2, 14)
    cluster_cols = range(14, 23)

    df_bikeid = pd.DataFrame.from_dict({'n_trips': df_bikes.ix[bikeid][month_cols], 'month': range(1, 13)})
    p_months = Bar(df_bikeid, label='month', values='n_trips', 
                   title='Trips by Month', title_text_font_size='20', 
                   ylabel='Count')
    script_months, div_months = components(p_months)
    
    lons = df_stations.longitude
    lats = df_stations.latitude
    names = df_stations.name
    clusters = df_stations.cluster+1
    sizes = [df_stations.groupby('cluster')['name'].count()[cl] for cl in df_stations.cluster]
    
    ns_trips = [int(df_bikes.ix[bikeid][cl+14]) for cl in df_stations.cluster]
    color_map = ['#ffffcc', '#ffeda0', '#fed976', '#feb24c', '#fd8d3c', '#fc4e2a', '#e31a1c', '#bd0026', '#800026']
    order_cluster = [int(CL[-1]) for CL in df_bikes.ix[bikeid][cluster_cols].order().index]
    converter = dict(zip(order_cluster, range(9)))
    colors = [color_map[converter[cl+1]] for cl in df_stations.cluster]
    
    map_options = GMapOptions(lat=41.8827, lng=-87.6227, map_type="roadmap", zoom=11)
    p_clusters = GMapPlot(x_range=Range1d(), y_range=Range1d(), 
                          map_options=map_options, title='Trips by Area')
    p_clusters.add_tools(PanTool(), WheelZoomTool(), BoxSelectTool(), PreviewSaveTool(), ResetTool(), HoverTool())
    source = ColumnDataSource(data=dict(lon=lons, lat=lats, radius=[12.5]*300, color=colors, 
                                        name=names, cluster=clusters, size=sizes, n_trips=ns_trips))
    circle = Circle(x="lon", y="lat", size="radius", fill_color="color", line_color=None, fill_alpha=1.0)
    p_clusters.add_glyph(source, circle)
    hover = p_clusters.select(dict(type=HoverTool))
    hover.point_policy = "follow_mouse"
    hover.tooltips = OrderedDict([("Station", "@name"), ("Area", "@cluster"), 
                                  ("Size", "@size stations"), ("Trips", "@n_trips")])
    script_clusters, div_clusters = components(p_clusters)
    
    return render_template('graph.html', 
                           bikeid=bikeid, n_trips=n_trips, n_maints=n_maints, 
                           n_maints_month=n_maints_month, n_maints_area=n_maints_area, 
                           script_months=script_months, div_months=div_months, 
                           script_clusters=script_clusters, div_clusters=div_clusters)

    @app.route('/analysis')
    def show_analysis():
        return render_template('analysis.html')
开发者ID:xuchenyu,项目名称:divvy_bike_flask,代码行数:67,代码来源:app.py


注:本文中的bokeh.models.GMapPlot.select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。