Skip to content

Commit b9f3da6

Browse files
committed
Automatically set the projection on output raster to match input layer
1 parent b567a6d commit b9f3da6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/plugins/heatmap/heatmap.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ void Heatmap::run()
110110
float cellsize = d.cellSizeX(); // or d.cellSizeY(); both have the same value
111111
float myDecay = d.decayRatio();
112112

113+
// Start working on the input vector
114+
QgsVectorLayer* inputLayer = d.inputVectorLayer();
115+
113116
// Getting the rasterdataset in place
114117
GDALAllRegister();
115118

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

130135
GDALRasterBand *poBand;
131136
poBand = emptyDataset->GetRasterBand( 1 );
@@ -153,8 +158,6 @@ void Heatmap::run()
153158
return;
154159
}
155160
poBand = heatmapDS->GetRasterBand( 1 );
156-
// Start working on the input vector
157-
QgsVectorLayer* inputLayer = d.inputVectorLayer();
158161

159162
QgsAttributeList myAttrList;
160163
int rField = 0;

0 commit comments

Comments
 (0)