ESRI ASC data into Blender - help please

Hello,

I have some LiDAR data from Geomatics that I’d like to import into Blender. I’ve spent days trying all sorts of open source GIS software to try and convert it to something Blender understands but I’m having no luck at all (other than making a height map image - but I want to retain the exact co-ordinates and scale of the data). I was wondering if someone could please help. I don’t think the contents of the ASC file are too complicated - a header and then the grid data.

I’ve attached a link to two of the tiles should anyone like to have a play for me! I only ask because hopefully someone can help and I’ve really spent far too long getting nowhere.

Many thanks,

Adam

https://dl.dropboxusercontent.com/u/5975316/Archive.zip

easy :slight_smile:

You start out with something like:


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


getval = lambda i: 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)


    


Then move on to


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


getval = lambda i: 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
    for i, row in enumerate(ofile):
        for j, coord in enumerate(row.split()):
            x = j * 0.01   #   cell x width
            y = i * 0.01   #   cell y width
            z = float(coord) 
            add_vert((x,y,z))
            
    print('done')
    print('last vertex:', verts[-1])



Execution will be a little slow for this preliminary implementation


and faces, +/- 1 million faces


Hi Zeffii,

I can’t thank you enough for this! I’m new to using scripts but got it working quite quickly. Tomorrow I will try joining several tiles together and getting the scale correct. Then I want to try and understand how you did the script - and so I may ask some questions!

Thanks again,

Adam

hi there i was wandering about some of the first steps. im no expert in coding so i dont really know what to do.

Karinexmachine: file-modified_original_with_skipping_whitespace-py should let you load the uk survey asc files, they are slightly different asc files, therefor the original script would not have worked straight away.

Hi Zeffii, I am trying to use your script to import the uk survey asc files, but when I try to import images with 0.5m resolution I get this error in the console:

ValueError: invalid literal for int<> with base 10: ‘0.5’

No problem with 1m resolution files.

Is there an easy way to fix it?

Thanks,
Luca

1 Like