Open brendancol opened 6 years ago
import datashader as ds
from datashader.bokeh_ext import InteractiveImage
from functools import partial
from datashader.utils import export_image
from datashader.colors import colormap_select, Greys9, Hot, viridis, inferno
from IPython.core.display import HTML, display
background = "black"
export = partial(export_image, export_path="export", background=background)
cm = partial(colormap_select, reverse=(background=="black"))
def create_image(x_range, y_range, w=plot_width, h=plot_height):
# query rbush for only rectangles inside of ranges
cvs = ds.Canvas(plot_width=w, plot_height=h, x_range=x_range, y_range=y_range)
agg = cvs.points(df, 'dropoff_x', 'dropoff_y', ds.count('passenger_count'))
img = tf.shade(agg, cmap=Hot, how='eq_hist')
return tf.dynspread(img, threshold=0.5, max_px=4)
p = base_plot(background_fill_color=background)
export(create_image(*NYC),"NYCT_hot")
InteractiveImage(p, create_image)
git fetch && git checkout brendan-notebook-changes
)gaussian_grid
centroids
propertyraster
property which returns 2d array (datafor xarray / datashader
)partition(npartitions=9)
method which break up rtree into N rtrees based on kmeans or some other clustering algo. on centroids. test usinggaussian_grid
data (future)to_parquet
method which write rtree to disk usingpyarrow
(future)