import datashader as ds import datashader.transfer_functions as tf import dask.diagnostics as diag import spatialpandas as spd import spatialpandas.io from datashader.utils import lnglat_to_meters %%time df = spd.io.read_parquet_dask('./data/osm-3billion.parq') df.head() def bounds(x_range, y_range): x,y = lnglat_to_meters(x_range, y_range) return dict(x_range=x, y_range=y) Earth = ((-180.00, 180.00), (-59.00, 74.00)) France = (( -12.00, 16.00), ( 41.26, 51.27)) Paris = (( 2.05, 2.65), ( 48.76, 48.97)) plot_width = 1000 plot_height = int(plot_width*0.5) cvs = ds.Canvas(plot_width=plot_width, plot_height=plot_height, **bounds(*Earth)) with diag.ProgressBar(), diag.Profiler() as prof, diag.ResourceProfiler(0.5) as rprof: agg = cvs.points(df, 'x', 'y') tf.shade(agg.where(agg > 15), cmap=["lightblue", "darkblue"]) def plot(x_range, y_range): cvs = ds.Canvas(plot_width=plot_width, plot_height=plot_height, **bounds(x_range, y_range)) agg = cvs.points(df, 'x', 'y') return tf.shade(agg, cmap=["lightblue","darkblue"]) %time plot(*France) %time plot(*Paris) from bokeh.io import output_notebook from bokeh.resources import CDN output_notebook(CDN, hide_banner=True) diag.visualize([prof, rprof]);