I need to import an ASC, which is a Digital Terrain Model, file into blender. Basically it's a matrix of points, each represented by a number corrisponding to his height. What's the best way to do that? Is there anything you know that it's pre build or I have to write my own loader in Phyton? Thanks

  • $\begingroup$ I think your best bet would be to convert asc to something standardized like obj first. $\endgroup$ – Vader Mar 10 '15 at 16:19
  • $\begingroup$ And how can I do that? Do you know? $\endgroup$ – BelottiGhilardi Mar 10 '15 at 16:22
  • $\begingroup$ The ESRI ASCII grid format seems to be pretty straight forward (see en.wikipedia.org/wiki/Esri_grid). If you do not have a converter for other formats, I think writing your own python code is your best option. $\endgroup$ – maddin45 Mar 10 '15 at 16:23
  • $\begingroup$ It's exactly that format, thanks. I'll look for a converter $\endgroup$ – BelottiGhilardi Mar 10 '15 at 16:27
  • 1
    $\begingroup$ DEMs are no supported natively, there used to be a plugin for very old versions of blender but no longer updated. Try converting to a format that blender can read before importing: wiki.blender.org/index.php/Dev:Ref/Outdated/Resources/… $\endgroup$ – user1853 Mar 11 '15 at 2:18

for one of my project i was using this addon: https://sourceforge.net/projects/pointcloudskin/files/latest/download?source=files

it did its job very well - just had to make sure the ASCII data is correct (x,y,z)

I am not sure if its compatible with 2.76a - but once you manage to import the data and skin the point cloud - you can always go for newer blender version.

He has also a CSV import addon - which also comes very handy in this matters.

As for the skinning process: it a bit of try and error process.

good luck

|improve this answer|||||

Last year I wrote a simple importer for ASC files (see: this blenderartists thread http://blenderartists.org/forum/archive/index.php/t-357605.html )



import bpy  
import time
import csv

A = time.time()

dfile = r"C:\Users\dealga\Desktop\Archive\SU8606_DSM_1M.asc"

getval = lambda i: int(next(i).split()[1])

with open(dfile) as ofile:
    ncols = getval(ofile)
    nrows = getval(ofile)
    xllcorner = getval(ofile)
    yllcorner = getval(ofile)
    cellsize = getval(ofile)
    NODATA_value = getval(ofile)

    print(ncols, nrows, xllcorner, yllcorner, cellsize, NODATA_value)

    # this will read the rest
    verts = []
    add_vert = verts.append
    asc_reader = csv.reader(ofile, delimiter=' ')

    # ni = nrows #? +1 -1
    # nj = ncols #? +1 -1
    ni = 1000
    nj = 1000

    for i, row in enumerate(asc_reader):
        if i >= ni:
        for j in range(int(ncols)):
            if j >= nj:
            z = (float(row[j]) / 60)
            x = j * 0.01   #   cell x width
            y = i * 0.01   #   cell y width

    print('last vertex:', verts[-1])

B = time.time()

total_time = B-A
print('total_time:', total_time)

faces = []
add_face = faces.append

# generate_edges, i = verts y, j = verts x
total_range = ((ni-1) * (nj))
indices = []
for i in range(total_range):
    if not ((i+1) % nj == 0):
        add_face([i, i+nj, i+nj+1, i+1])

# do your own error handling
mesh_data = bpy.data.meshes.new("LIDAR_mesh_data3")  
mesh_data.from_pydata(verts, [], faces)  

LIDAR_object = bpy.data.objects.new("LIDAR_Object3", mesh_data)  

scene = bpy.context.scene    
LIDAR_object.select = True        
|improve this answer|||||

I also needed to import an ASC file into Blender. I found that the open source program MeshLab could import ASC files and then export it to an OBJ file, which I could import in Blender. Pretty easy actually.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.