OGS
createRaster.cpp File Reference

Detailed Description

Definition in file createRaster.cpp.

#include <tclap/CmdLine.h>
#include <memory>
#include "BaseLib/Logging.h"
#include "BaseLib/MPI.h"
#include "BaseLib/TCLAPArguments.h"
#include "BaseLib/TCLAPOutput.h"
#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-2025, OpenGeoSys Community "
35 "(http://www.opengeosys.org)",
37 BaseLib::TCLAPOutput tclapOutput;
38 cmd.setOutput(&tclapOutput);
39
40 TCLAP::ValueArg<std::string> output_arg("o", "output",
41 "Output (.asc). Name of the output"
42 "raster file",
43 true, "", "OUTPUT_FILE");
44 cmd.add(output_arg);
45 TCLAP::ValueArg<std::size_t> n_rows("r", "n_rows", "number of rows", false,
46 1000, "NUM_ROWS");
47 cmd.add(n_rows);
48 TCLAP::ValueArg<std::size_t> n_cols("c", "n_cols", "number of columns",
49 false, 1000, "NUM_COLS");
50 cmd.add(n_cols);
51 TCLAP::ValueArg<double> cell_size("s", "cell_size",
52 "cell size, "
53 "(min = 0)",
54 false, 10.0, "CELL_SIZE");
55 cmd.add(cell_size);
56 TCLAP::ValueArg<double> ll_y_arg(
57 "",
58 "ll_y",
59 "y coordinate of lower left point of axis aligned rectangular region",
60 false,
61 0,
62 "LL_Y");
63 cmd.add(ll_y_arg);
64 TCLAP::ValueArg<double> ll_x_arg(
65 "",
66 "ll_x",
67 "x coordinate of lower left point of axis aligned rectangular region",
68 false,
69 0,
70 "LL_X");
71 cmd.add(ll_x_arg);
72
73 auto log_level_arg = BaseLib::makeLogLevelArg();
74 cmd.add(log_level_arg);
75 cmd.parse(argc, argv);
76
77 BaseLib::MPI::Setup mpi_setup(argc, argv);
78 BaseLib::initOGSLogger(log_level_arg.getValue());
79
81 n_cols.getValue(),
82 n_rows.getValue(),
83 0,
84 GeoLib::Point{{ll_x_arg.getValue(), ll_y_arg.getValue(), 0}},
85 cell_size.getValue(),
86 -9999};
87 std::vector<double> raster_data(header.n_cols * header.n_rows, 0.0);
88 GeoLib::Raster const raster{header, raster_data.begin(), raster_data.end()};
89
91 output_arg.getValue());
92
93 return EXIT_SUCCESS;
94}
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
std::vector< double >::const_iterator begin() const
Definition Raster.h:96
TCLAP::ValueArg< std::string > makeLogLevelArg()
void initOGSLogger(std::string const &log_level)
Definition Logging.cpp:64
GITINFOLIB_EXPORT const std::string ogs_version
Contains the relevant information when storing a geoscientific raster data.
Definition Raster.h:28

References GeoLib::Raster::begin(), BaseLib::initOGSLogger(), BaseLib::makeLogLevelArg(), GitInfoLib::GitInfo::ogs_version, and FileIO::AsciiRasterInterface::writeRasterAsASC().