Hi Bishwarup, <div><br></div><div>some time ago I needed something like that. I got it with gdal and osr. </div><div><br></div><div>Here is the Python snippet:</div><div>---------------------------------------------------------------</div>
<div># <b>Python terminal</b>: First, get the transform parameters, you'll use them after in the code</div><div><div>dataset = gdal.Open("/ruta/archivo_original.tif", gdal.GA_ReadOnly)</div><div>parameters = ds.GetGeoTransform()</div>
<div>---------------------------------------------------------------</div><div># <b>On a separate Python file</b></div><div>import numpy</div><div>from osgeo import gdal</div><div>from osgeo import osr</div><div><br></div>
<div># Cargue del archivo que contiene la matriz</div><div>array = numpy.loadtxt("/ruta/archivo_cp1",delimiter=';')</div><div><br></div><div># Formato de salida</div><div>out_driver = gdal.GetDriverByName("GTiff")</div>
<div><br></div><div># Creación del DataSet de salida</div><div>outds = out_driver.Create("/ruta/archivo_salida.tif", 1272, 787, 1,</div><div> gdal.GDT_Float32, options=["COMPRESS=PACKBITS","TFW=YES"] )</div>
<div><br></div><div># <b>Here you should put the parameters you got before</b></div><div>outds.SetGeoTransform([552910.96327099996,28.5,0.0,422591.15634099999,0.0,-28.5])</div><div><br></div><div># Definir el sistema de referencia de la imagen de salida</div>
<div>srs = osr.SpatialReference()</div><div>srs.ImportFromEPSG( 32618 )</div><div>outds.SetProjection( srs.ExportToWkt() )</div><div><br></div><div># Escribir la matriz 'array' en la primera banda de la imagen de salida</div>
<div>outband = outds.GetRasterBand( 1 )</div><div>outband.WriteArray( array )</div></div><div>---------------------------------------------------------------</div><div> </div><div>Hope it helps you.</div><div><br></div><div>
<br></div><div>Regards, </div><div><br></div><div>Germán</div><div><br><br><div class="gmail_quote">On Tue, Nov 2, 2010 at 9:21 AM, Barry Rowlingson <span dir="ltr"><<a href="mailto:b.rowlingson@lancaster.ac.uk" target="_blank">b.rowlingson@lancaster.ac.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div></div><div>On Tue, Nov 2, 2010 at 1:53 PM, Bishwarup Banerjee<br>
<<a href="mailto:bishwarup.banerjee@gmail.com" target="_blank">bishwarup.banerjee@gmail.com</a>> wrote:<br>
> Dear All,<br>
><br>
> Can any body help me to get and set projection parameters for raster files?<br>
><br>
> I am doing some map calculation using PIL and the data is losing projection,<br>
> so want to re project the raster files.<br>
><br>
> The language I am using is Python on windows platform..<br>
<br>
</div></div> Assuming this is a qgis question...<br>
<br>
If you get the layer in 'l' then l.crs() gets you a coordinate<br>
reference system object:<br>
<br>
>>> l.crs()<br>
<qgis.core.QgsCoordinateReferenceSystem object at 0xb3b44ac><br>
<br>
and hence:<br>
<br>
>>> l.crs().toProj4()<br>
PyQt4.QtCore.QString(u'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')<br>
<br>
and to set it, just use setCrs with a QgsCoordinateReferenceSystem object.<br>
<br>
Barry<br>
_______________________________________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>-----------<br> |\__ <br>(:>__)(<br> |/ <br><br>Soluciones Geoinformáticas Libres <br><a href="http://geotux.tuxfamily.org/" target="_blank">http://geotux.tuxfamily.org/</a><br>
</div>