Skip to content

Commit

Permalink
Automatically set the projection on output raster to match input layer
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 7, 2013
1 parent b567a6d commit b9f3da6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/plugins/heatmap/heatmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ void Heatmap::run()
float cellsize = d.cellSizeX(); // or d.cellSizeY(); both have the same value
float myDecay = d.decayRatio();

// Start working on the input vector
QgsVectorLayer* inputLayer = d.inputVectorLayer();

// Getting the rasterdataset in place
GDALAllRegister();

Expand All @@ -126,6 +129,8 @@ void Heatmap::run()
double geoTransform[6] = { myBBox.xMinimum(), cellsize, 0, myBBox.yMinimum(), 0, cellsize };
emptyDataset = myDriver->Create( d.outputFilename().toUtf8(), columns, rows, 1, GDT_Float32, NULL );
emptyDataset->SetGeoTransform( geoTransform );
// Set the projection on the raster destination to match the input layer
emptyDataset->SetProjection( inputLayer->crs().toWkt().toLocal8Bit().data() );

GDALRasterBand *poBand;
poBand = emptyDataset->GetRasterBand( 1 );
Expand Down Expand Up @@ -153,8 +158,6 @@ void Heatmap::run()
return;
}
poBand = heatmapDS->GetRasterBand( 1 );
// Start working on the input vector
QgsVectorLayer* inputLayer = d.inputVectorLayer();

QgsAttributeList myAttrList;
int rField = 0;
Expand Down

0 comments on commit b9f3da6

Please sign in to comment.