Is datashader imprecise on larger dataset?

46 Views Asked by At

I am trying to visualize shortest path algorithm and what nodes they visit through their searches. Ive done so using folium (not scalable) and datashader (scalable). However when visualizing visited nodes on top of all roads I get some weird results in datashader. In the picture from datashader, grey is a road and blue is if it has visited that road, but it draws blue ontop of empty spaces like water. This example can be seen in the attached picture of folium (right) and datashader (left) as datashader connects the two peninsulas and folium doesn't. And there is also some grey pixels in the middle that should have been visited, i.e be blue. My question is then, is this because datashader is imprecise or because of me?

picture of the two results

Here is how I've implemented datashader ` def visiualize_figures(self, visited_edges, lats, lons, start, end, algo, test_map): dirname = os.path.dirname(file) dir = f"maps/map-{algo}-{test_map[4]}"

    # plot visited nodes
    visited_lats = np.full((len(visited_edges) * 2), 0, dtype=np.float64)
    visited_lons = np.full((len(visited_edges) * 2), 0, dtype=np.float64)
    i = 0
    for p, c in visited_edges:
        visited_lats[i] = lats[p]
        visited_lons[i] = lons[p]
        visited_lats[i + 1] = lats[c]
        visited_lons[i + 1] = lons[c]
        i += 2
    df_visited = pd.DataFrame({
        'lat': visited_lats,
        'lon': visited_lons
    })
    # plot all edges
    df_background = pd.DataFrame({
        'lat': lats,
        'lon': lons
    })

    plot_width, plot_height = get_h_w(test_map)
    minLon = min(lons)
    maxLon = max(lons)
    minLat = min(lats)
    maxLat = max(lats)

    cvs1 = ds.Canvas(plot_width=plot_width, plot_height=plot_height, x_range=(minLon, maxLon), y_range=(minLat, maxLat))

    agg_background = cvs1.points(df_background, 'lon', 'lat')
    agg_visited = cvs1.points(df_visited, 'lon', 'lat')
    img_background = ds.tf.set_background(ds.tf.shade(agg_background, how="cbrt", cmap=["lightgrey"]), 'white')
    img_visited = ds.tf.set_background(ds.tf.shade(agg_visited, how="cbrt", cmap=["blue"]))

    img = ds.tf.set_background(ds.tf.stack(img_background, img_visited))
    export_image(img, os.path.join(dirname, dir))

    print(f"Shortest path and visted nodes visualized in file \'{dir}\'\n")`

Ive tried correcting my list of visted_edges but that should be correct.

0

There are 0 best solutions below