Concentration of Issues on a Floorplan Heat Map

I am trying to make a heatmap, showing the concentration of coordination issues in different areas/rooms on a floor plan. I have read all the previous heat map related topics and attempted to use the solutions/discussions from those, but I’m still hitting a wall with achieving the expected result.

In Dynamo, I got the centroid point for every room on the level and tied those points to the room number. Then I imported an excel file with coordination issues and their locations (room numbers). I have compared the room numbers in the excel list to the model rooms and tied the associated room centroid point to each issue in the list:

Room 101 = Point XYZ
Issues #1 = Room 101
so Issue #1 = Point XYZ and so on

So the expected result would be a heat map where the colors react to the concentration of issue points (areas/rooms with the most number of issues are red, areas with few to no issues are green or blue).

Two issues I’m running into:

  1. GeometryColor.BySurfaceColors is failing with an error “you must supply a two dimensional list of colors”. My color range node set up appears to match what others in previous topics have had with no errors but the only way to get the node to not fail is to add a list.flatten to my color list, and I’m not sure if flattening the list is causing issue 2.
  2. Surface color does not appear to be aligned with where the points are concentrated, and the colors are banded rather than the smooth heat map gradients others have made.

What am I doing wrong…

CI Heat Map.dyn (107.5 KB)

The color range you supply should be a list of lists essentially representing rows x columns. Since the output you’re seeing is a single row, I’m guessing you only have one sublist.

What you’re actually creating is a grid of points with associated colors. If you have specific points (room locations) you want to color, you actually have an attractor on a grid that you’re generating colors for based on distance.

An easier alternative might be to just color code rooms based on the number of issues they have.

Okay, I was able to fix the color listing issue.

I could just color each room… but I wanted the “pretty” heat map gradient look for an overlay. I guess my logic on what the result would be was wrong.

Thanks!

This is essentially what you’re after. The list of colors represents an array of rows containing colors equally spaced within that row. The list builds those rows from bottom to top.

Here’s a basic method to create a heatmap using numpy.histogram2d
You will have to tailor the bins, range and weights to suit your requirements

import numpy as np

x, y = IN[0]

range = [[0, 5], [0, 5]]

H, _, _ = np.histogram2d(x, y, bins=5, range=range, weights=None)

# Normalise to [0, 1]
H = (H - H.min()) / np.ptp(H)

OUT = H.tolist()