OGS
createRaster.cpp File Reference

Detailed Description

Definition in file createRaster.cpp.

#include <tclap/CmdLine.h>
#include <mpi.h>
#include <memory>
#include "GeoLib/AABB.h"
#include "GeoLib/IO/AsciiRasterInterface.h"
#include "GeoLib/Point.h"
#include "GeoLib/Raster.h"
#include "InfoLib/GitInfo.h"
Include dependency graph for createRaster.cpp:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 26 of file createRaster.cpp.

27{
28 TCLAP::CmdLine cmd(
29 "Create a raster of specified size at specified origin where every "
30 "pixel has the value zero.\n\n"
31 "OpenGeoSys-6 software, version " +
33 ".\n"
34 "Copyright (c) 2012-2024, OpenGeoSys Community "
35 "(http://www.opengeosys.org)",
37
38 TCLAP::ValueArg<std::string> output_arg("o", "output",
39 "Name of the output raster (*.asc)",
40 true, "", "output file name");
41 cmd.add(output_arg);
42 TCLAP::ValueArg<std::size_t> n_rows("r", "n_rows", "number of rows", false,
43 1000, "positive integer value");
44 cmd.add(n_rows);
45 TCLAP::ValueArg<std::size_t> n_cols("c",
46 "n_cols",
47 "number of columns",
48 false,
49 1000,
50 "positive integer value");
51 cmd.add(n_cols);
52 TCLAP::ValueArg<double> cell_size("s", "cell_size", "cell size", false,
53 10.0, "double value");
54 cmd.add(cell_size);
55 TCLAP::ValueArg<double> ll_y_arg(
56 "",
57 "ll_y",
58 "y coordinate of lower left point of axis aligned rectangular region",
59 false,
60 0,
61 "double value");
62 cmd.add(ll_y_arg);
63 TCLAP::ValueArg<double> ll_x_arg(
64 "",
65 "ll_x",
66 "x coordinate of lower left point of axis aligned rectangular region",
67 false,
68 0,
69 "double value");
70 cmd.add(ll_x_arg);
71
72 cmd.parse(argc, argv);
73
74#ifdef USE_PETSC
75 MPI_Init(&argc, &argv);
76#endif
77
79 n_cols.getValue(),
80 n_rows.getValue(),
81 0,
82 GeoLib::Point{{ll_x_arg.getValue(), ll_y_arg.getValue(), 0}},
83 cell_size.getValue(),
84 -9999};
85 std::vector<double> raster_data(header.n_cols * header.n_rows, 0.0);
86 GeoLib::Raster const raster{header, raster_data.begin(), raster_data.end()};
87
89 output_arg.getValue());
90
91#ifdef USE_PETSC
92 MPI_Finalize();
93#endif
94 return EXIT_SUCCESS;
95}
static void writeRasterAsASC(GeoLib::Raster const &raster, std::string const &file_name)
Writes an Esri asc-file.
Class Raster is used for managing raster data.
Definition Raster.h:49
GITINFOLIB_EXPORT const std::string ogs_version
Contains the relevant information when storing a geoscientific raster data.
Definition Raster.h:28

References GitInfoLib::GitInfo::ogs_version, and FileIO::AsciiRasterInterface::writeRasterAsASC().