Create model from XYZ data points I'm trying to create a 3D heat map model out of data that I have from a csv file. I have a few thousand data points with XYZ coordinates.

I'm able to import the data into blender as a point cloud with this python script, however I would like to create a model with solid faces. Is there a way when importing the data to somehow join the points to create faces instead of generating thousands of separate points?

Currently, this what I have in terms of point cloud

The end product would look something like this (minus the texture) and obviously the model wouldn't be as regular as this one

Any help is greatly appreciated!
From the file you provided, here is the result:



Effectively, this is not as regular as the sample image in the question!!

This script works only if we have a rectangular grid along X and Y.

Here is commented code (tell me if some additional explanations are needed):

import bpy
import csv
from operator import itemgetter

csvfile = open('G:\\Telechargements\\Heatmap_ES_output_01.csv')

inFile = csv.reader(csvfile, delimiter=',', quotechar='"')
# skip header
inFile.__next__()

#Read and sort the vertices coordinates (sort by x and y)
vertices = sorted( [(float(r[0]), float(r[1]), float(r[2])) for r in inFile], key = itemgetter(0,1) )

#********* Assuming we have a rectangular grid *************
xSize = next( i for i in range( len(vertices) ) if vertices[i][0] != vertices[i+1][0] ) + 1 #Find the first change in X
ySize = len(vertices) // xSize

#Generate the polygons (four vertices linked in a face)
polygons = [(i, i - 1, i - 1 + xSize, i + xSize) for i in range( 1, len(vertices) - xSize ) if i % xSize != 0]

name = "grid"
mesh = bpy.data.meshes.new( name ) #Create the mesh (inner data)
obj = bpy.data.objects.new( name, mesh ) #Create an object

obj.data.from_pydata( vertices, [], polygons ) #Associate vertices and polygons

obj.scale = (1, 5, 0.2) #Scale it (if needed)
for p in obj.data.polygons: #Set smooth shading (if needed)
    p.use_smooth = True

bpy.context.scene.objects.link( obj ) #Link the object to the scene




Blender 2.8

For 2.8:

The last line:

bpy.context.scene.objects.link( obj )


should be replaced by:

bpy.context.scene.collection.objects.link( obj )