NASA LRO Lola & MGS Mola IMG Importer (up. 2011/06/25)

(ValterVB) #1

Hi to all
Here you can find my script for Blender 2.5. Script
Now is on SVN

#ver. 0.0.1: -First version
#ver. 0.0.2: -Add check on path and file
#            -Check on selected coordinates more complete
#ver. 1.1.0: -Optimized for less memory
#ver. 1.1.1: -Correct bug for real value of the High (bad error).
#             now it's less artistic, bat more real Always possible use
#             the old formula. check Magnify (x4)
#            -Correct the bug for directory with dot in the name
#            -Add some warning and more information
#            -Add slider for the scale and info on it
#ver. 1.1.2: -Word correction
#            -Correct the problem for Unix (Upper lower case)
#              If the Ext of the file selected from user is upper
#              than the second file is Upper and Viceversa.
#              (I can't verify because i have Win)
#ver. 1.1.3: -Little fix for previous fix on upper/lower case
#ver. 1.1.4: -Fix for recent API changes. Thanks to Filiciss.
#            -Some code cleaning (PEP8)
#ver. 1.1.5: -Fix for recent API changes. Thanks to Filiciss.
#ver. 1.1.6: -Fix for API changes, and restore Scale factor
#ver. 1.1.7: -Fix for API changes. Move some code out of draw
#ver. 1.1.8: --Add a reset button to reset the UI

Wiki page

With this script you can import alimetric data of the Moon and Mars at different resolutions.
You can found the data for the Moon here:
You must download the IMG file and the LBL file with the same name. Use the file that starting with LDEM no LDEC.
The first number after LDEM is the resolution: 4=4 pixel/deg16 =16 pix/deg and so on

You can found the data for Mars here:
Always you must download the IMG and the LBL file and keep in the same directory.


  1. You must choice the file that you want imported (IMG or LBL is the same)
  2. Then you must select the coordinates that you want import (latitude and longitude).
    Northernmost Lat must be > Southernmost Lat
    Westernmost Long must be < Easternmos Long
    All the coordinates are in decimal format.
    Before that you press Import check the number of vertex that you import.
    the Import button is visible only when all is OK

North-South axis is set on Blender Y axis.
East-West axis is set on Blender X axis.

Some Esxample-All these examples are exaggerated in heigh:
Tycho crater on the Moon

Olympus Mons on Mars

Full Moon (my old experiment)


(RickyBlender) #2

sorry but he link at top requires to sign in !

the moon looks amazing man!

what size of data file to generate this moon?

and how many vertices ?

Thanks for this nice script in 2.5

(zeffii) #3

i also can’t figure out how to download this. looks really promising :slight_smile:

(Meta-Androcto) #4

thanks for the cool script!
you need a google account to d/l I think.
(I had no probs getting it)

you could try for the file uploads.

(ValterVB) #5

Very strange.
Well, here the link to pasteall:


(superhero) #6

ValterVB just curios to know when you import a (IMG or LBL is the same) normally how much vertices are imported i,m looking at your screen shot for It Says number of vertices to be imported 2165633 thats huge des it also have a option to import in low res?

(ValterVB) #7

For superhero: My record is 36,869,760, (I have used 18.4 GB of RAM).

Option for import Low res (for now :eyebrowlift:): use low density file, for example LDEM 4

Example for the moon:
LDEM 4 Global map: 1,036,800 vertex, File=2 MB
LDEM 16 Global map: 16,562,889 vertex, File=31.6 MB
LDEM 64 Global map: 264,902,625 vertex, File=506.3 MB
LDEM 128 Global map: 1,059,541,441 vertex, File=1,98 GB
LDEM 256 1/4 map: 10616832 vertex, File=1,98 GB
LDEM 512 1/16 map: 10616832 vertex, File=1,98 GB

TODO: Now I read all the the file, I must change it for reading only the data that i need.

For RickyBlender: for the full Moon, I have used all the point of LDEM 64, with multple rendering and then I merged the image Here you can found the full resolution (4000x4000 pix)


(RickyBlender) #8

where can we find the craters names with coordinates for moon or other bodies ?

the first pic of moon is awsome but not certain it can be done on 32 bits vista!
the craters looks almost real !

also how much time did this take to render?

i did a test in 256 this morning
and i can load the ldem4 fro the moon
but then at thebottom of panel when i try to change the long lat coordiantes
it goes back to 0!
so should i be able to change theses coordinates to get area i want ?

also can you put back here in this thread how DWG showing how the coordinates works like you had in the old thread!

old 2.49 thread

that would help eveybody trying to work with this script to better understand it

other thread is

i added the 2 files IMG and LDEM 4 in same folder with blend file
but now i run it again and get the following error

location:<unknown location>:-1
Traceback (most recent call last):
File “”, line 406, in draw
NameError: global name ‘MINIMUM_LATITUDE’ is not defined

what did i do wrong here?

by the way i use the same old maps from the old folder of 2.49
unless theses maps format have changed !

thanks happy 2.5

(ValterVB) #9

Well, a little explanation:

Coordinates: Latitude (on the left) and Longitude (on the right).

User interface Explanation:
With 1, 2, 3, and 4 you choose the region that you want import.

1 Must be higher (northern most) of 2
4 Must be higher (eastern most) of 3

Valid values for 1 and 2 are shown in top of the user interface (first row after Import File):
Minimum Latitude and Maximum Latitude

Valid values for 3 and 4 are shown in top of the user interface (second row after Import File):
Westernmost Longitude, Easternmost Longitude

The extreme values are automatically setting. If the values are not consistent with these rule the Import button is not displayed.

Quote from old thread

ValterVB: So if you want from North pole to Equator you must set Northernmost=90 and Southernmost=0
if you want from South pole to Equator you must set Northernmost=0 and Southernmost=-90
Longitude are in the other side From 0 to 360
If you want from North Pole to South pole but only 1 half of the planet, set
Northernmost=90 Southernmost=-90 and for ex. Westernmost=0 Easternmost=180
RickyBlender: so for latitude
North pole is at + 90 degrees
Equator is at 0 degrees
South Pole is at - 90 degrees

goes from 0 to 360 degrees

so to get a full sphere
from latitude +90
to latitude -90

from longitude 0
to longitude 360

where can we find the craters names with coordinates for moon or other bodies ?
good question :yes:
for the Moon start from here

Ricky for your Error can you post the LBL file, and the complete name with path of your IMG file?

and Happy New Year to all :slight_smile:

(RickyBlender) #10

the path and old LBL file

C:\Users\RJ\moonmapping\ filename
all files are located in this folder

old lbl file

/*** This label describes three data files along with map projection /
** information. The files described have the same name as this label /
** but different extensions. They are: /
** .IMG - PDS image file, stored as a binary two-dimensional array /
** .JP2 - The same image stored with JPEG2000 compression /
** .XML - An auxiliary text file in XML, provided to aid display of /
** the JPEG2000 image with certain image processing software /
** The map projection information includes parameters that are specific /
** to this image. They are intended to be used with the general map /
** projection descriptions in the file indicated by the keyword /
** ^DATA_SET_MAP_PROJECTION. That file is found in the CATALOG directory /
** of this archive. /
START_TIME = 2009-07-13T17:33:17.246
STOP_TIME = 2009-12-17T23:59:59.193
PRODUCT_CREATION_TIME = 2010-03-15T00:00:00
DESCRIPTION = "This data product is a shape map (radius)
of the Moon at a resolution of 4 pixels per degree, based on altimetry
data acquired by the LOLA instrument. The preliminary LOLA Laser data are
the source for this data set. Since the altitude of the LRO spacecraft was
higher than the 30-70 km orbit for which LOLA was designed, many of the
ranges are noise. The ground tracks were interpolated using the Generic
Mapping Tools programs ‘surface’ and ‘grdblend’. Map values are referred
to a radius of 1737400 m.
This label describes three objects. The first is an IMG file in the form
of a binary table with one row for each 0.25 degree latitude. The second is
a JP2 file of the same filename, that uses a jpeg 2000 compression to
render the image. The third is an auxiliary xml file that contains
extensible markup language that is interpreted by GDAL readers (
DESCRIPTION = “Each sample represents height relative to a
reference radius (OFFSET) and is generated using preliminary LOLA data
produced by the LOLA team.”
LINES = 720
OFFSET = 1737400.

hope this is still good as file data !

when running script i get only the script name no fields in panel!

happy new year

and happy 2.5

(ValterVB) #11

If is all, isn’t complete. Try with link

Right click and download or alt+left click.


(RickyBlender) #12

srry did not upload the whole file

but is it good to work in 2.5
or should i download again theses files ?

and eaht about the error in panel with no buttons at all
just the title and error!


(RickyBlender) #13

ok tested with your new data file

and get same error
File “”, line 406, in draw
NameError: global name ‘MINIMUM_LATITUDE’ is not defined

seems it cannot see the ‘MINIMUM_LATITUDE’
if the IMG file is there or not!

very strange cause the first time i ran it i got more fields
but now i get only the script name at top of panel and no fields at all!

i have built 2.56!


(RickyBlender) #14

i did another test here
open a new file pass script into text editor and ran it
and now i get all the fields
but get this error when loading up the LBL file

location:<unknown location>:-1
Traceback (most recent call last):
File “Text”, line 456, in draw
File “Text”, line 133, in RealLat
File “Text”, line 116, in LineToLat
ZeroDivisionError: int division or modulo by zero
location:<unknown location>:-1

note don’t understand why the old file is not working anymore !


(ValterVB) #15

Ricky, I have found a little bug, I update more late the script. Probably you have selected the directory, but not the file.



(ValterVB) #16

I have updated the script. Link on first post


(RickyBlender) #17

ok tested the last version and still get the same last error for Zero division!

location:<unknown location>:-1
Traceback (most recent call last):
File “”, line 462, in draw
File “”, line 139, in RealLat
File “”, line 122, in LineToLat
ZeroDivisionError: int division or modulo by zero

i got the pasteall version!

happy new year !

(ValterVB) #18

Well, step by step if you can :slight_smile:

  1. You used these file?

  2. Are the file in the same directory and the directory haven’t a dot in the name?

  3. After selected the file, you can see the path and the name in the user interface? (for ex. L:\PDS Planet\Moon\LRO Lola DEM 4\LDEM_4.LBL)

  4. The script version is 0.0.2?

  5. Try this: when you select the file, check (or uncheck) Relative Path on the left of the window where you select the file.

  6. Thanks


(RickyBlender) #19

got it i guess

it’s the relative paht thing on the ledt of files/ folders window!

can you explain what it does and how it works!

now i was able to add some coordinates into fields

but then how do you execute it ?

i mean i don’t have the import line at botton of panel !


(DaveRM) #20


First post but have been lurking for awhile. :slight_smile:

I was having the same problem as RickyBlender.

I was able to use the script when I loaded the Factory Settings, and then run the script.

I was unable to load the Tool Shelf items of the script when I was using my User Settings,
as described by RB above.

I am on a XP Pro Box using the 2.56 zip package from

Thanks for the script.