<div dir="ltr"><div><div>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...<br>
<br>---------<br></div>Temporary script to create r.in.xyz compatible input files, one file per band of M3...<br>---------<br><br>#!/usr/bin/env python<br></div>#if older python use:<br><div>#from __future__ import *<br><br>
print("Usage: m3xyz.py LOCfile.IMG ReflectFile.IMG")<br># For image processing<br><br>from math import *<br>import numpy<br><br>from osgeo import gdalnumeric<br>from osgeo import gdal<br><br>from osgeo.gdal_array import *<br>
from osgeo.gdalconst import *<br><br><br>import os, sys<br>#Load Loc file<br><br>#loc = LoadFile( sys.argv[1] )<br>#ref = LoadFile( sys.argv[2] )<br>loc = "M3G20090111T013904_V03_LOC.IMG"<br>ref = "M3G20090111T013904_V01_RFL.IMG"<br>
out = "outascii"<br><br>#Location dataset<br>ds_loc = gdal.Open(loc, GA_ReadOnly) <br>ds_loc_cols = ds_loc.RasterXSize<br>ds_loc_rows = ds_loc.RasterYSize<br>ds_loc_bands = ds_loc.RasterCount<br>ds_loc_driver = ds_loc.GetDriver().LongName<br>
<br>b1 = ds_loc.GetRasterBand(1)<br>longitude = b1.ReadAsArray(0, 0, ds_loc_cols, ds_loc_rows).astype(numpy.float)<br>b2 = ds_loc.GetRasterBand(2)<br>latitude = b2.ReadAsArray(0, 0, ds_loc_cols, ds_loc_rows).astype(numpy.float)<br>
b3 = ds_loc.GetRasterBand(3)<br>radius = b3.ReadAsArray(0, 0, ds_loc_cols, ds_loc_rows).astype(numpy.float)<br><br>#Reflectance dataset<br>ds_ref = gdal.Open(ref, GA_ReadOnly) <br>ds_ref_cols = ds_ref.RasterXSize<br>ds_ref_rows = ds_ref.RasterYSize<br>
ds_ref_bands = ds_ref.RasterCount<br>ds_ref_driver = ds_ref.GetDriver().LongName<br><br>for n in range (ds_ref.RasterCount):<br>    f=open(out+"_"+str(n)+".xyz","w")<br>    b = ds_ref.GetRasterBand(n+1)<br>
    d = b.ReadAsArray(0, 0, ds_ref_cols, ds_ref_rows).astype(numpy.float)<br>    for row in range(ds_ref_rows):<br>        for col in range(ds_ref_cols):<br>            f.write(str(longitude[row,col])+str(latitude[row,col])+str(d[row,col]))<br>
<br>    f.close()<br>    del d,b,f<br><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 28 November 2013 10:47, Yann Chemin <span dir="ltr"><<a href="mailto:ychemin@gmail.com" target="_blank">ychemin@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div>Hi,<br><br></div>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).<br>

<br></div>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). <br><br></div>What would be the best option to import with reprojection using all pixels coordinates available...<br>

</div>What about importing in 3D?<br><br></div>Thank you,<br>Yann<span class="HOEnZb"><font color="#888888"><br><div><div><div><br><br clear="all"><div><div><div><div><div><br>-- <br>----
</div></div></div></div></div></div></div></div></font></span></div>
</blockquote></div><br><br clear="all"><br>-- <br>----
</div>