[GRASS-dev] importing M3 data (Chandrayaan Moon Multispectral Mapper) in GRASS

Yann Chemin ychemin at gmail.com
Sun Dec 1 06:49:27 PST 2013

Following up, I made this script to create an ascii file per band of M3.
Inputs are L1B LOC.IMG (ENVI format actually) for X,Y,Z, and L2 REF.IMG
(also ENVI, but many bands). output are ascii*.xyz, will update with final
scripts once it will have finished the process once...

Temporary script to create r.in.xyz compatible input files, one file per
band of M3...

#!/usr/bin/env python
#if older python use:
#from __future__ import *

print("Usage: m3xyz.py LOCfile.IMG ReflectFile.IMG")
# For image processing

from math import *
import numpy

from osgeo import gdalnumeric
from osgeo import gdal

from osgeo.gdal_array import *
from osgeo.gdalconst import *

import os, sys
#Load Loc file

#loc = LoadFile( sys.argv[1] )
#ref = LoadFile( sys.argv[2] )
loc = "M3G20090111T013904_V03_LOC.IMG"
ref = "M3G20090111T013904_V01_RFL.IMG"
out = "outascii"

#Location dataset
ds_loc = gdal.Open(loc, GA_ReadOnly)
ds_loc_cols = ds_loc.RasterXSize
ds_loc_rows = ds_loc.RasterYSize
ds_loc_bands = ds_loc.RasterCount
ds_loc_driver = ds_loc.GetDriver().LongName

b1 = ds_loc.GetRasterBand(1)
longitude = b1.ReadAsArray(0, 0, ds_loc_cols,
b2 = ds_loc.GetRasterBand(2)
latitude = b2.ReadAsArray(0, 0, ds_loc_cols,
b3 = ds_loc.GetRasterBand(3)
radius = b3.ReadAsArray(0, 0, ds_loc_cols, ds_loc_rows).astype(numpy.float)

#Reflectance dataset
ds_ref = gdal.Open(ref, GA_ReadOnly)
ds_ref_cols = ds_ref.RasterXSize
ds_ref_rows = ds_ref.RasterYSize
ds_ref_bands = ds_ref.RasterCount
ds_ref_driver = ds_ref.GetDriver().LongName

for n in range (ds_ref.RasterCount):
    b = ds_ref.GetRasterBand(n+1)
    d = b.ReadAsArray(0, 0, ds_ref_cols, ds_ref_rows).astype(numpy.float)
    for row in range(ds_ref_rows):
        for col in range(ds_ref_cols):


    del d,b,f

On 28 November 2013 10:47, Yann Chemin <ychemin at gmail.com> wrote:

> Hi,
> Chandrayaan M3 data is rather strange, it has products without
> Georeference (i.e. Reflectance bands etc) and it has a .LOC image set (3
> bands), with one latitude band, one longitude band and one "altitude" band
> (actually a distance to center of the moon).
> So each pixel of a product has indeed a coordinate, stored into a map.
> Problem is that the products are not projected datasets (rectangular kind
> of swath storage).
> What would be the best option to import with reprojection using all pixels
> coordinates available...
> What about importing in 3D?
> Thank you,
> Yann
> --
> ----

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20131201/34efb965/attachment.html>

More information about the grass-dev mailing list