diff --git a/Applications/DataExplorer/DataView/MshView.cpp b/Applications/DataExplorer/DataView/MshView.cpp
index ef6591caae8e294ec2bc3d015f98222d8c57a440..8bb3ad669fe4e168aa39e8039671e9ea8f6144b2 100644
--- a/Applications/DataExplorer/DataView/MshView.cpp
+++ b/Applications/DataExplorer/DataView/MshView.cpp
@@ -25,6 +25,7 @@
 
 #include "FileIO/SHPInterface.h"
 #include "FileIO/TetGenInterface.h"
+#include "FileIO/AsciiRasterInterface.h"
 
 #include "MeshLib/Mesh.h"
 #include "MeshLib/Node.h"
@@ -164,7 +165,17 @@ void MshView::openMap2dMeshDialog()
 	result->setName(dlg.getNewMeshName());
 	if (dlg.useRasterMapping())
 	{
-		if (!MeshLib::MeshLayerMapper::layerMapping(*result, dlg.getRasterPath(), dlg.getNoDataReplacement()))
+		std::unique_ptr<GeoLib::Raster> raster{
+		    FileIO::AsciiRasterInterface::readRaster(dlg.getRasterPath())};
+		if (!raster)
+		{
+			OGSError::box(QString::fromStdString(
+			    "Error mapping mesh. Could not read raster file " +
+			    dlg.getRasterPath()));
+			return;
+		}
+		if (!MeshLib::MeshLayerMapper::layerMapping(*result, *raster,
+		                                            dlg.getNoDataReplacement()))
 		{
 			OGSError::box("Error mapping mesh.");
 			return;
diff --git a/MeshLib/MeshGenerators/MeshLayerMapper.cpp b/MeshLib/MeshGenerators/MeshLayerMapper.cpp
index 2c6fc86431579fb0826df45b14ce412063c9c1cc..288fd7047219619e82167424ab0bc78ea85a06ba 100644
--- a/MeshLib/MeshGenerators/MeshLayerMapper.cpp
+++ b/MeshLib/MeshGenerators/MeshLayerMapper.cpp
@@ -18,8 +18,6 @@
 
 #include "logog/include/logog.hpp"
 
-#include "FileIO/AsciiRasterInterface.h"
-
 #include "GeoLib/Raster.h"
 
 #include "MathLib/MathTools.h"
@@ -231,18 +229,6 @@ void MeshLayerMapper::addLayerToMesh(const MeshLib::Mesh &dem_mesh, unsigned lay
     }
 }
 
-bool MeshLayerMapper::layerMapping(MeshLib::Mesh &new_mesh, std::string const& rasterfile, double noDataReplacementValue = 0.0)
-{
-	const GeoLib::Raster *raster(FileIO::AsciiRasterInterface::readRaster(rasterfile));
-	if (! raster) {
-		ERR("MshLayerMapper::layerMapping - could not read raster file %s", rasterfile.c_str());
-		return false;
-	}
-	const bool result = layerMapping(new_mesh, *raster, noDataReplacementValue);
-	delete raster;
-	return result;
-}
-
 bool MeshLayerMapper::layerMapping(MeshLib::Mesh &new_mesh, GeoLib::Raster const& raster, double noDataReplacementValue = 0.0)
 {
 	if (new_mesh.getDimension() != 2)
diff --git a/MeshLib/MeshGenerators/MeshLayerMapper.h b/MeshLib/MeshGenerators/MeshLayerMapper.h
index fffd8f32a70f4fe3f863dc8120625048dee44260..e4c4fa8e7815c114148d96c9fff9d1f9efce2341 100644
--- a/MeshLib/MeshGenerators/MeshLayerMapper.h
+++ b/MeshLib/MeshGenerators/MeshLayerMapper.h
@@ -56,14 +56,9 @@ public:
 	                        double noDataReplacementValue = 0.0);
 
 	/**
-	* Maps the elevation of nodes of a given 2D mesh according to the raster specified by the file path.
-	* At locations wher no information is given, node elevation is set to noDataReplacementValue.
-	*/
-	static bool layerMapping(MeshLib::Mesh &mesh, const std::string &rasterfile, double noDataReplacementValue);
-
-	/**
-	* Maps the elevation of nodes of a given 2D mesh according to the raster. At locations wher no
-	* information is given, node elevation is set to noDataReplacementValue.
+	* Maps the elevation of nodes of a given 2D mesh according to the raster. At
+	* locations where no information is given, node elevation is set to
+	* noDataReplacementValue.
 	*/
 	static bool layerMapping(MeshLib::Mesh &mesh, const GeoLib::Raster &raster, double noDataReplacementValue);