OGS
createRaster.cpp
Go to the documentation of this file.
1
12#include <tclap/CmdLine.h>
13
14#include <memory>
15
16#include "BaseLib/MPI.h"
17#include "GeoLib/AABB.h"
19#include "GeoLib/Point.h"
20#include "GeoLib/Raster.h"
21#include "InfoLib/GitInfo.h"
22
23int main(int argc, char* argv[])
24{
25 TCLAP::CmdLine cmd(
26 "Create a raster of specified size at specified origin where every "
27 "pixel has the value zero.\n\n"
28 "OpenGeoSys-6 software, version " +
30 ".\n"
31 "Copyright (c) 2012-2024, OpenGeoSys Community "
32 "(http://www.opengeosys.org)",
34
35 TCLAP::ValueArg<std::string> output_arg("o", "output",
36 "Name of the output raster (*.asc)",
37 true, "", "output file name");
38 cmd.add(output_arg);
39 TCLAP::ValueArg<std::size_t> n_rows("r", "n_rows", "number of rows", false,
40 1000, "positive integer value");
41 cmd.add(n_rows);
42 TCLAP::ValueArg<std::size_t> n_cols("c",
43 "n_cols",
44 "number of columns",
45 false,
46 1000,
47 "positive integer value");
48 cmd.add(n_cols);
49 TCLAP::ValueArg<double> cell_size("s", "cell_size", "cell size", false,
50 10.0, "double value");
51 cmd.add(cell_size);
52 TCLAP::ValueArg<double> ll_y_arg(
53 "",
54 "ll_y",
55 "y coordinate of lower left point of axis aligned rectangular region",
56 false,
57 0,
58 "double value");
59 cmd.add(ll_y_arg);
60 TCLAP::ValueArg<double> ll_x_arg(
61 "",
62 "ll_x",
63 "x coordinate of lower left point of axis aligned rectangular region",
64 false,
65 0,
66 "double value");
67 cmd.add(ll_x_arg);
68
69 cmd.parse(argc, argv);
70
71 BaseLib::MPI::Setup mpi_setup(argc, argv);
72
74 n_cols.getValue(),
75 n_rows.getValue(),
76 0,
77 GeoLib::Point{{ll_x_arg.getValue(), ll_y_arg.getValue(), 0}},
78 cell_size.getValue(),
79 -9999};
80 std::vector<double> raster_data(header.n_cols * header.n_rows, 0.0);
81 GeoLib::Raster const raster{header, raster_data.begin(), raster_data.end()};
82
84 output_arg.getValue());
85
86 return EXIT_SUCCESS;
87}
Definition of the AABB class.
Definition of the AsciiRasterInterface class.
Definition of the Point class.
Git information.
Definition of the GeoLib::Raster class.
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
int main(int argc, char *argv[])
GITINFOLIB_EXPORT const std::string ogs_version
Contains the relevant information when storing a geoscientific raster data.
Definition Raster.h:28