26int main(
int argc,
char* argv[])
29 "Assigns the pixel information of a raster file to a scalar array of a "
30 "specified 2D mesh. Data will be assigned to a node array by default. "
31 "Adding information to cell arrays is also possible, pixel values at "
32 "the centre of the cell will be used in this case. Note that large "
33 "differences in resolution between cell size of the mesh and pixel "
34 "size of the raster can give unexpected results. A no-data value will "
35 "be added in case of missing or transparent values.\n\n"
36 "OpenGeoSys-6 software, version " +
39 "Copyright (c) 2012-2025, OpenGeoSys Community "
40 "(http://www.opengeosys.org)",
43 TCLAP::ValueArg<double> nodata_arg(
45 "The no data value used for missing values "
50 TCLAP::SwitchArg set_cells_arg(
"c",
"cell-array",
51 "Assigns raster data to cell array");
52 cmd.add(set_cells_arg);
54 TCLAP::SwitchArg set_nodes_arg(
55 "n",
"node-array",
"Assigns raster data to node array (default)");
56 cmd.add(set_nodes_arg);
58 TCLAP::ValueArg<std::string> array_name_arg(
59 "s",
"scalar-name",
"The name of the newly created scalar array.",
true,
61 cmd.add(array_name_arg);
62 TCLAP::ValueArg<std::string> raster_arg(
63 "r",
"raster",
"Input (.asc). Name of the input raster file",
true,
"",
67 TCLAP::ValueArg<std::string> output_arg(
68 "o",
"output",
"Output (.vtu). Name of the output mesh file",
true,
"",
71 TCLAP::ValueArg<std::string> input_arg(
72 "i",
"input",
"Input (.vtu). Name of the input mesh file",
true,
"",
76 cmd.add(log_level_arg);
77 cmd.parse(argc, argv);
82 bool const create_cell_array(set_cells_arg.isSet());
83 bool const create_node_array =
84 (create_cell_array) ? set_nodes_arg.isSet() :
true;
86 std::string
const& mesh_name = input_arg.getValue();
87 std::string
const& output_name = output_arg.getValue();
88 std::string
const& raster_name = raster_arg.getValue();
90 std::unique_ptr<MeshLib::Mesh>
const mesh(
92 if (mesh->getDimension() > 2)
94 ERR(
"Method can not be applied to 3D meshes.");
98 std::unique_ptr<GeoLib::Raster>
const raster(
101 if (create_node_array)
104 *mesh, *raster, nodata_arg.getValue(), array_name_arg.getValue());
108 ERR(
"Error assigning raster data to scalar node array");
111 INFO(
"Created node array {:s}", array_name_arg.getValue());
114 if (create_cell_array)
117 *mesh, *raster, nodata_arg.getValue(), array_name_arg.getValue());
121 ERR(
"Error assigning raster data to scalar cell array");
124 INFO(
"Created cell array {:s}", array_name_arg.getValue());