Digital Elevation Model Import Script-still valid?

I’m having difficulty making the Digital Elevation Model (DEM) Importer script work. I found it on http://uaraus.altervista.org/index.php?filename=en/content/categories/Blender/DEM_importer.html

I’m using DEM Importer Version 0.0.4 on a Windows XP, SP2 machine using Python 2.4 and Blender 2.41.
I’m in the U.S. I downloaded N32W090.hgt data as a test from SRTM datab website. Unzipped it. I input the directory for the data so the PC knew where to look on the Files input screen. I bounded the area in the input screen with latitude 31 and 33 and longitude 89 and 91. The console gives me an error: "Specified file do not exist. No matching file name. Giving up. Verts: 22500, Vertexcolors: 22500, faces: 22201, deleting object…

I’ve tried different bounding lats and longs, I’ve changed the Downsampling value and Scale Factor value. I’ve tried everything I know to no avail.
Has a data format changed? Should I use (-) values for Western Hemisphere for the longitude?
Would someone let me know what to try next or if there is a bug?

Regards,

3DUser

I kludged my own such script… going to be interesting to extract it from the .blend

import Blender
    
starttime = Blender.sys.time()

filename = "E:\\Downloads\\maps\\los_angeles-w\\los_angeles-w.dem"

f = open(filename,"r")

# bah! [I don't want to do it this way]
fstr = f.read()

# lines gets the point across, but is technically the wrong name
lines = fstr.split()

print "
BEGINING"
#print len(lines)

mesh = Blender.NMesh.GetRaw()
Blender.NMesh.PutRaw(mesh, 's')
x, y, numverts = 0, 0, 0

index = 51 # a hack?

while index < len(lines):
    line = lines[index]
    index += 1
    try:
        val = float(line)
        
        if val > 0.0 and val < 100000.0:
            mesh.verts.append(Blender.NMesh.Vert(x,y,val/130.0))
        else:
            mesh.verts.append(Blender.NMesh.Vert(x,y,-1.0))
        numverts += 1
        y += 1
        if y % 1210 == 0:
            x += 1
            y = 0
    except ValueError:
        print line,
print
        
# add faces
i = 0
while i < numverts-1211:
    if (i+1) % 1210 != 0:
        #mesh.faces.append(Blender.NMesh.Face([mesh.verts[i], mesh.verts[i+1]   ]))
        mesh.faces.append(Blender.NMesh.Face([mesh.verts[i+1211], mesh.verts[i+1],mesh.verts[i], mesh.verts[i+1210] ]))
    i += 1

mesh.update(1)

f.close()
print "DONE?", Blender.sys.time()-starttime

Digital Elevation Model Import Script-still valid?
As with the 99% of the code out there, a bug can still happen.
Positively, if the statement “there could be a bug” is equivalent to “no more valid”, then it could be no more valid.:slight_smile:

I bounded the area in the input screen with latitude 31 and 33 and longitude 89 and 91.
For the dataset it should be between 32 and 33 lat and -90 and -89.
Anyway the script should intercept automatically which files are available giving a partial coverage of the requested area.

I’ve tried everything I know to no avail.
Yes, these things could be very disappointing

Has a data format changed?
Not in my knowledge: it should be the raw data …
I’ll do a check this night (at work no ftp allowed) with your dataset

Should I use (-) values for Western Hemisphere for the longitude?
Yes + for N and E, - for S and W

Would someone let me know what to try next or if there is a bug?
Easy enough, in the doc and on the website there is the e-mail of the script author :slight_smile:

@z3r0_d
I will not publish this script as an example of python programming;)
Always available for suggestions on how to improve it …

Made it work.
For Western Hemisphere using N32W90 coordinates, the data input looked similar to this:

       32

-91 -90
31

Regards,
3Duser

Happy to hear it.
Still from my test to get data from N32W090 I had to insert

    33
-90   -89
    32

obtaining a “low profile” (meaning nearly flat) terrain.
Check continues …

3DUser, thank you for your feedback
get in touch if I can help.

More feedback -
The first time I made this perform, I was at work. I tried to duplicate the results at home and was unable to do so until I found my errors.
Here were my errors at home until I fixed them -
1.
When I downloaded the data, I obtained SRTM-1 data, not the SRTM-3 data. From this URL ftp://e0srp01u.ecs.nasa.gov/srtm/version2/ I had picked the wrong folder. Lesson learned: Read the instructions carefully.

I tried to duplicate what I had produced at work. I had two datasets there and that’s why my coordinates worked there. So, I tried the coordinates you provided. Yours worked here at home. I must remember that in this application, the coordinates of interest are in the lower left rather than in another location as in other applications. Lesson learned: Read the instructions carefully.

For a test, I set the sampling at 1 with a factor of 100. I stressed the computer. It had too many faces for Blender to use Vertex Paint.

I retried this and set the sampling at 5. It worked. The area of interest is mostly flat. I was able to adjust the colors to see slight differences.

Don’t know if my experience will help or not, but I can only hope so.

Thanks for your work.

Regards,
3DUser