GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
n_arrays_io.c File Reference
#include <math.h>
#include <grass/N_pde.h>
#include <grass/raster.h>
#include <grass/glocale.h>
Include dependency graph for n_arrays_io.c:

Go to the source code of this file.

Functions

N_array_2dN_read_rast_to_array_2d (char *name, N_array_2d *array)
 Read a raster map into a N_array_2d structure. More...
 
void N_write_array_2d_to_rast (N_array_2d *array, char *name)
 Write a N_array_2d struct to a raster map. More...
 
N_array_3dN_read_rast3d_to_array_3d (char *name, N_array_3d *array, int mask)
 Read a volume map into a N_array_3d structure. More...
 
void N_write_array_3d_to_rast3d (N_array_3d *array, char *name, int mask)
 Write a N_array_3d struct to a volume map. More...
 

Function Documentation

◆ N_read_rast3d_to_array_3d()

N_array_3d* N_read_rast3d_to_array_3d ( char *  name,
N_array_3d array,
int  mask 
)

Read a volume map into a N_array_3d structure.

The volume map is opened in the current region settings. If no N_array_3d structure is provided (NULL pointer), a new structure will be allocated with the same data type as the volume map and the size of the current region. The array offset will be set to 0.

If a N_array_3d structure is provided, the values from the volume map are casted to the N_array_3d type. The array must have the same size as the current region.

The new created or the provided array is returned. If the reading of the volume map fails, Rast3d_fatal_error() will be invoked.

Parameters
name* char - the name of an existing volume map
array* N_array_3d - an existing array or NULL
maskint - 0 = false, 1 = ture : if a mask is presenent, use it with the input volume map
Returns
N_array_3d * - the existing or new allocated array

Definition at line 253 of file n_arrays_io.c.

References Cell_head::cols, Cell_head::depths, NULL, Cell_head::rows, and x.

◆ N_read_rast_to_array_2d()

N_array_2d* N_read_rast_to_array_2d ( char *  name,
N_array_2d array 
)

Read a raster map into a N_array_2d structure.

The raster map will be opened in the current region settings. If no N_array_2d structure is provided (NULL pointer), a new structure will be allocated with the same data type as the raster map and the size of the current region. The array offset will be set to 0.

If a N_array_2d structure is provided, the values from the raster map are casted to the N_array_2d type. The array must have the same size as the current region.

The new created or the provided array are returned. If the reading of the raster map fails, G_fatal_error() will be invoked.

Parameters
name* char - the name of an existing raster map
array* N_array_2d - an existing array or NULL
Returns
N_array_2d * - the existing or new allocated array

Definition at line 47 of file n_arrays_io.c.

References x.

◆ N_write_array_2d_to_rast()

void N_write_array_2d_to_rast ( N_array_2d array,
char *  name 
)

Write a N_array_2d struct to a raster map.

A new raster map is created with the same type as the N_array_2d. The current region is used to open the raster map. The N_array_2d must have the same size as the current region. If the writing of the raster map fails, G_fatal_error() will be invoked.

Parameters
arrayN_array_2d *
namechar * - the name of the raster map
Returns
void

Definition at line 173 of file n_arrays_io.c.

References Cell_head::cols, count, Cell_head::rows, and x.

◆ N_write_array_3d_to_rast3d()

void N_write_array_3d_to_rast3d ( N_array_3d array,
char *  name,
int  mask 
)

Write a N_array_3d struct to a volume map.

A new volume map is created with the same type as the N_array_3d. The current region is used to open the volume map. The N_array_3d must have the same size as the current region. If the writing of the volume map fails, Rast3d_fatal_error() will be invoked.

Parameters
arrayN_array_3d *
namechar * - the name of the volume map
maskint - 1 = use a 3d mask, 0 do not use a 3d mask
Returns
void

Definition at line 385 of file n_arrays_io.c.

References Cell_head::cols, count, Cell_head::depths, NULL, Cell_head::rows, and x.