diff --git a/src/app/georeferencer/qgsgeorefmainwindow.cpp b/src/app/georeferencer/qgsgeorefmainwindow.cpp index a91d593c8ef9..dbb8737b88cf 100644 --- a/src/app/georeferencer/qgsgeorefmainwindow.cpp +++ b/src/app/georeferencer/qgsgeorefmainwindow.cpp @@ -1138,6 +1138,19 @@ void QgsGeoreferencerMainWindow::addRaster( const QString &file ) options.skipCrsValidation = true; mLayer = std::make_unique< QgsRasterLayer >( file, QStringLiteral( "Raster" ), QStringLiteral( "gdal" ), options ); + // guess a reasonable target CRS to use by default + if ( mLayer->crs().isValid() ) + { + // if source raster already is already georeferenced, assume we'll be keeping the same CRS + mTargetCrs = mLayer->crs(); + } + // otherwise use the previous target crs, unless that's never been set + else if ( !mTargetCrs.isValid() ) + { + // in which case we'll use the current project CRS + mTargetCrs = QgsProject::instance()->crs(); + } + // add layer to map canvas mCanvas->setLayers( QList() << mLayer.get() ); @@ -1192,7 +1205,7 @@ bool QgsGeoreferencerMainWindow::loadGCPs( QString &error ) { QgsCoordinateReferenceSystem actualDestinationCrs; const QList< QgsGcpPoint > points = QgsGCPList::loadGcps( mGCPpointsFileName, - QgsProject::instance()->crs(), + mTargetCrs, actualDestinationCrs, error ); if ( !error.isEmpty() )