From 8a12a0be2287ff019e9178714722500420561e49 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Thu, 10 Feb 2022 09:42:41 +1000 Subject: [PATCH] When loading gcp points for a raster which is already georeferenced, assume the source points are in the raster's IF there's no explicit crs information in the .points file --- src/app/georeferencer/qgsgeorefmainwindow.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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() )