def industry_size_map(data_list, data_values_list, industry_col):
    for ind, data_df in enumerate(data_list):
        renderer = gv.renderer('bokeh')
        gv_points = gv.Points(data_df, ['longitude', 'latitude'],
                              [industry_col, 'YeshuvAtarSvivatiMenifa'])
        data_df.rename(columns={industry_col: ""})
        tooltips = [("Amount", "@" + industry_col),
                    ("Location", '@YeshuvAtarSvivatiMenifa')]
        hover = HoverTool(tooltips=tooltips)
        # map_plot =gvts.CartoLight.options(width=500, height=800, xaxis=None, yaxis=None, show_grid=False) * gv_points
        map_plot = (gvts.CartoLight * gv_points).opts(
            opts.Points(width=400,
                        height=700,
                        alpha=0.3,
                        hover_line_color='black',
                        color=color_looper_bokeh(ind),
                        line_color='black',
                        xaxis=None,
                        yaxis=None,
                        tools=[hover],
                        size=dim(industry_col) * 10,
                        hover_fill_color=None,
                        hover_fill_alpha=0.5))
        dir = save_geoviews(map_plot=map_plot,
                            file_name="map " + industry_col + "-" +
                            data_values_list[ind],
                            renderer=renderer,
                            output_folder="Output_files")
예제 #2
0
def pick_heading_from_map(image_file_name,
                          camera_center_lon,
                          camera_center_lat,
                          dx=0.015,
                          dy=0.015):

    # Google Satellite tiled basemap imagery url
    url = 'https://mt1.google.com/vt/lyrs=s&x={X}&y={Y}&z={Z}'

    # TODO
    # # allow large images to be plotted or force resampling to thumbnail
    # # load the image with xarray and plot with hvplot to handle larger images
    img, subplot_width, subplot_height = hv_plot_raster(image_file_name)

    # create the extent of the bounding box
    extents = (camera_center_lon - dx, camera_center_lat - dy,
               camera_center_lon + dx, camera_center_lat + dy)

    # run the tile server
    tiles = gv.WMTS(url, extents=extents)

    points = gv.Points(
        [(camera_center_lon, camera_center_lat, 'camera_center')],
        vdims='location')

    point_stream = hv.streams.PointDraw(source=points)

    base_map = (tiles * points).opts(
        opts.Points(width=subplot_width,
                    height=subplot_height,
                    size=10,
                    color='black',
                    tools=["hover"]))

    row = pn.Row(img, base_map)

    server = row.show(threaded=True)

    condition = True
    while condition == True:
        try:
            if len(point_stream.data['x']) == 2:
                server.stop()
                condition = False
        except:
            pass

    projected = gv.operation.project_points(point_stream.element,
                                            projection=ccrs.PlateCarree())
    df = projected.dframe()
    df['location'] = ['camera_center', 'flight_direction']

    heading_lon = df.x[1]
    heading_lat = df.y[1]

    heading = hsfm.geospatial.calculate_heading(camera_center_lon,
                                                camera_center_lat, heading_lon,
                                                heading_lat)

    return heading
예제 #3
0
 def make_view(self):
     dfc = stations[stations['contractName'] == self.city_name]
     gv_df = gv.Dataset(
         dfc[['longitude', 'latitude', 'name', 'bikes_available_total']])
     points = gv_df.to(gv.Points, ['longitude', 'latitude'],
                       ['name', 'bikes_available_total'])
     return (tiles * points).opts(
         opts.Points(tools=['hover'],
                     size=dim('bikes_available_total'),
                     color='bikes_available_total',
                     cmap='viridis'))
예제 #4
0
def pick_points_from_basemap_tiles(tiles, utm_zone=None):

    if utm_zone == None:
        location = gv.Points([], vdims="vertices")

    else:
        location = gv.Points([], vdims="vertices", crs=ccrs.UTM(utm_zone))

    point_stream = PointDraw(source=location)
    base_map = (tiles * location).opts(
        opts.Points(width=500,
                    height=500,
                    size=12,
                    color='black',
                    tools=["hover"]))
    app = pn.panel(base_map)
    return app, point_stream
예제 #5
0
    opts.HexTiles(
        colorbar=True,
        projection=ccrs.NorthPolarStereo(),
        tools=['hover'],
        width=600,
        height=500,
        gridsize=20,
        cmap=default_cmap,
        clabel='',
        show_legend=False,
        aggregator=np.mean,
    ),
    opts.Polygons(line_color='k', fill_color=None, line_width=3),
    opts.Feature(line_color='k', line_width=1, scale='110m'),
    opts.Shape(line_width=0.8),
    opts.Points(projection=ccrs.NorthPolarStereo(), )
]

opts_timeseries_bk = [
    opts.Scatter(
        invert_yaxis=True,
        s=3,
        alpha=.4,
        axiswise=True,
        color='g',
        show_legend=False,
        # fontsize={'xlabel':18, 'ylabel':18, 'ticks':16}
    ),
    opts.ErrorBars(
        color='k',
        alpha=.3,
예제 #6
0
def plot_grids(data,fields,plot_type):
    if len(data) == 2: 
        ds,grid_ds = data
        
        if fields == 'Sources':
            print('Plotting Sources..')
            event_times_seconds = xr.DataArray(ds.event_time.values.astype('<m8[s]')/86400,dims='number_of_events')
            event_times_seconds.shape,ds.event_time.shape
            dss = ds.copy()
            dss['times'] = event_times_seconds.astype(int)

            xr_dataset = gv.Dataset(hv.Points((dss.event_longitude.values, dss.event_latitude.values,dss.times.values), 
                kdims=[hv.Dimension('x'),hv.Dimension('y')],vdims=['time']))

            fig = gv.tile_sources.Wikipedia.opts(width=900, height=900) * xr_dataset.to.points(['x','y']).opts(opts.Points(color='time'))

        else:
            print(plot_type)
            z = grid_ds.flash_extent_density
            x = grid_ds.grid_longitude.values
            y = grid_ds.grid_latitude.values

            # get xarray dataset, suited for handling raster data in pyviz
            xr_dataset = gv.Dataset(hv.Image((x, y, np.log10(z.mean(axis=0))), bounds=(x.min(),y.min(),x.max(),y.max()), 
                    kdims=[hv.Dimension('x'),  hv.Dimension('y')], datatype=['grid']))

            # create contours from image
            gv.FilledContours(xr_dataset)
            fig = gv.tile_sources.Wikipedia.opts(width=900, height=900) * xr_dataset.to.image(['x', 'y']).opts(cmap='cubehelix', alpha=0.8)#gv.FilledContours(xr_dataset).opts(cmap='viridis', alpha=0.5)


        responsive = pn.pane.HoloViews(fig, config={'responsive': True})
        return(responsive)
    
    else:
        grid_ds = data
        print('No Data Processed')
        if fields == 'Sources':
            xr_dataset = gv.Dataset(hv.Points((np.repeat(-101.1,1), np.repeat(32,2),np.repeat(10,2)), 
                kdims=[hv.Dimension('x'),hv.Dimension('y')],vdims=['time']))

            fig = gv.tile_sources.Wikipedia.opts(width=900, height=900) * xr_dataset.to.points(['x','y']).opts(opts.Points(color='time'))

        elif plot_type == 'Grids':
            z = np.random.randn(10,(100,100))
            x = np.repeat(-101.1,100) 
            y = np.repeat(32,100)
            
           

            # get xarray dataset, suited for handling raster data in pyviz
            xr_dataset = gv.Dataset(hv.Image((x, y, np.log10(z)), bounds=(x.min(),y.min(),x.max(),y.max()), 
                    kdims=[hv.Dimension('x'),  hv.Dimension('y')], datatype=['grid']))

            # create contours from image
            gv.FilledContours(xr_dataset)
            fig = gv.tile_sources.Wikipedia.opts(width=900, height=900) * xr_dataset.to.image(['x', 'y']).opts(cmap='cubehelix', alpha=0.8)#gv.FilledContours(xr_dataset).opts(cmap='viridis', alpha=0.5)


        responsive = pn.pane.HoloViews(fig, config={'responsive': True})
        return(responsive)
예제 #7
0
def draw(data):
    gv.extension('bokeh')

    df = pd.DataFrame(data, columns=['mag', 'lng', 'lat', 'lokasyon', 'date'])

    earthquakes_gv_points = gv.Points(df, ['lng', 'lat'],
                                      ['lokasyon', 'mag', 'date'])

    gvts.CartoLight
    gvts.CartoLight * earthquakes_gv_points
    gvts.CartoLight.options(
        width=1000, height=800, xaxis=None, yaxis=None,
        show_grid=False) * earthquakes_gv_points
    earthquakes_plot = (gvts.CartoLight * earthquakes_gv_points).opts(
        opts.Points(width=980,
                    height=700,
                    alpha=0.3,
                    xaxis=None,
                    yaxis=None,
                    size=np.sqrt(dim('mag')) * 20))

    earthquakes_plot = (gvts.CartoLight * earthquakes_gv_points).opts(
        opts.Points(width=980,
                    height=700,
                    alpha=0.3,
                    hover_line_color='black',
                    line_color='black',
                    xaxis=None,
                    yaxis=None,
                    tools=['hover'],
                    size=np.sqrt(dim('mag')) * 20))

    from bokeh.models import HoverTool
    tooltips = [
        ('Magnitude', '@mag'),
        ('Date', '@date'),
        ('Location', '@lokasyon'),
        ('Longitude', '$x'),
        ('Latitude', '$y'),
    ]

    hover = HoverTool(tooltips=tooltips)

    earthquakes_plot = (gvts.CartoLight * earthquakes_gv_points).opts(
        opts.Points(width=980,
                    height=700,
                    alpha=0.3,
                    hover_line_color='black',
                    line_color='black',
                    xaxis=None,
                    yaxis=None,
                    tools=[hover],
                    size=np.sqrt(dim('mag')) * 20,
                    hover_fill_color=None,
                    hover_fill_alpha=0.5))

    return (earthquakes_plot).opts(
        opts.Graph(edge_selection_line_color='black',
                   edge_hover_line_color='red',
                   edge_line_width=1,
                   edge_line_alpha=0.01,
                   edge_nonselection_line_alpha=0.01,
                   width=800,
                   height=600))
예제 #8
0
def pick_camera_location(image_file_path,
                         center_lon,
                         center_lat,
                         dx=0.030,
                         dy=0.030):

    # Google Satellite tiled basemap imagery url
    url = 'https://mt1.google.com/vt/lyrs=s&x={X}&y={Y}&z={Z}'

    # TODO
    # # allow large images to be plotted or force resampling to thumbnail
    # # load the image with xarray and plot with hvplot to handle larger images
    img, subplot_width, subplot_height = hsfm.utils.hv_plot_raster(
        image_file_path)

    # create the extent of the bounding box
    extents = (center_lon - dx, center_lat - dy, center_lon + dx,
               center_lat + dy)

    # run the tile server
    tiles = gv.WMTS(url, extents=extents)

    points = gv.Points([(center_lon, center_lat, 'starting_center')],
                       vdims='image_file_name')

    point_stream = hv.streams.PointDraw(source=points)

    base_map = (tiles * points).opts(
        opts.Points(width=subplot_width,
                    height=subplot_height,
                    size=10,
                    color='black',
                    tools=["hover"]))

    row = pn.Row(img, base_map)

    server = row.show(threaded=True)

    condition = True
    while condition == True:
        try:
            if len(point_stream.data['x']) == 2:
                server.stop()
                condition = False
        except:
            pass

    projected = gv.operation.project_points(point_stream.element,
                                            projection=ccrs.PlateCarree())

    image_file_basename = os.path.splitext(
        os.path.basename(image_file_path))[0]

    df = projected.dframe()
    df['image_file_name'] = ['starting_center', image_file_basename]
    df = df.drop([0])

    x = df.x.values[0]
    y = df.y.values[0]

    return x, y, image_file_basename