Skip to content
Permalink
Browse files
Use epsg number for output crs in rastercalculator if possible (ticket
…#3649)

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15815 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Apr 23, 2011
1 parent 732325d commit 6e2f9643330c0b3c259c8030820988eeca00100a
Showing with 16 additions and 2 deletions.
  1. +16 −2 src/analysis/raster/qgsrastercalculator.cpp
@@ -23,6 +23,7 @@
#include <QProgressDialog>

#include "gdalwarper.h"
#include <ogr_srs_api.h>

#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800
#define TO8(x) (x).toUtf8().constData()
@@ -117,8 +118,21 @@ int QgsRasterCalculator::processCalculation( QProgressDialog* p )
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() ) );
char* crsWKT = 0;
OGRSpatialReferenceH ogrSRS = OSRNewSpatialReference( NULL );
const QgsCoordinateReferenceSystem& outputCrs = rl->crs();
int epsgCode = outputCrs.epsg();
if ( epsgCode > 0 && OSRImportFromEPSG( ogrSRS, epsgCode ) == CE_None )
{
OSRExportToWkt( ogrSRS, &crsWKT );
GDALSetProjection( outputDataset, crsWKT );
}
else
{
GDALSetProjection( outputDataset, TO8( rl->crs().toWkt() ) );
}
OSRDestroySpatialReference( ogrSRS );
CPLFree( crsWKT );
}
}

0 comments on commit 6e2f964

Please sign in to comment.