6
#include <grass/raster3d.h>
11
* Writes the cell-values of <em>map</em> in ascii format to file
12
* <em>fname</em>. The values are organized by horizontal slices.
19
void Rast3d_write_ascii(void *map, const char *fname)
26
int rows, cols, depths, typeIntern;
28
Rast3d_get_coords_map(map, &rows, &cols, &depths);
29
typeIntern = Rast3d_tile_type_map(map);
36
else if ((fp = fopen(fname, "w")) == NULL)
37
Rast3d_fatal_error("Rast3d_write_ascii: can't open file to write\n");
39
for (z = 0; z < depths; z++) {
40
for (y = 0; y < rows; y++) {
41
fprintf(fp, "z y x %d %d (%d - %d)\n", z, y, 0, cols - 1);
42
for (x = 0; x < cols; x++) {
43
Rast3d_get_value_region(map, x, y, z, d1p, typeIntern);
45
if (typeIntern == FCELL_TYPE)
46
fprintf(fp, "%.18f ", *f1p);
48
fprintf(fp, "%.50f ", d1);