def heatmap (d, bins=(100, 100), smoothing=1.3, cmap='jet'):
def getx (pt):
return pt.coords[0][0]
def gety (pt):
return pt.coords[0][1]
x = list(d.geometry.apply(getx))
y = list(d.geometry.apply(gety))
heatmap, xedges, yedges = np.histogram2d(y, x, bins=bins)
extent = [yedges[0], yedges[-1], xedges[-1], xedges[0]] # bin edges along the x and y dimensions, ordered
# why are we taking log?
logheatmap = np.log(heatmap)
logheatmap[np.isneginf(logheatmap)] = 0
logheatmap = ndimage.filters.gaussian_filter(logheatmap, smoothing, mode='nearest')
return (logheatmap, extent)
评论列表
文章目录