[QGIS Commit] r15581 - trunk/qgis/src/analysis/raster

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Mar 23 12:08:19 EDT 2011


Author: mhugent
Date: 2011-03-23 09:08:19 -0700 (Wed, 23 Mar 2011)
New Revision: 15581

Modified:
   trunk/qgis/src/analysis/raster/qgsrastercalculator.cpp
Log:
Write projection info to raster calculator output

Modified: trunk/qgis/src/analysis/raster/qgsrastercalculator.cpp
===================================================================
--- trunk/qgis/src/analysis/raster/qgsrastercalculator.cpp	2011-03-23 14:11:12 UTC (rev 15580)
+++ trunk/qgis/src/analysis/raster/qgsrastercalculator.cpp	2011-03-23 16:08:19 UTC (rev 15581)
@@ -110,6 +110,19 @@
     return 1;
   }
   GDALDatasetH outputDataset = openOutputFile( outputDriver );
+
+  //copy the projection info from the first input raster
+  if ( mRasterEntries.size() > 0 )
+  {
+    QgsRasterLayer* rl = mRasterEntries.at( 0 ).raster;
+    if ( rl )
+    {
+      //proj format would be better, but is not supported e.g. for writing to GeoTiff
+      GDALSetProjection( outputDataset, TO8( rl->crs().toWkt() ) );
+    }
+  }
+
+
   GDALRasterBandH outputRasterBand = GDALGetRasterBand( outputDataset, 1 );
 
   float outputNodataValue = -FLT_MAX;



More information about the QGIS-commit mailing list