Loading...
Searching...
No Matches
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_2d * | N_read_rast_to_array_2d (char *name, N_array_2d *array)
| Read a raster map into a N_array_2d structure.
void | N_write_array_2d_to_rast (N_array_2d *array, char *name)
| Write a N_array_2d struct to a raster map.
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.
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.

## 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
  mask | int - 0 = false, 1 = true : 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 G_fatal_error(), G_find_raster3d(), G_message(), G_percent(), N_alloc_array_3d(), N_put_array_3d_d_value(), N_put_array_3d_f_value(), N_put_array_3d_value_null(), name, NULL, 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 44 of file n_arrays_io.c.

References G_fatal_error(), G_free(), G_get_set_window(), G_incr_void_ptr(), G_message(), G_percent(), N_alloc_array_2d(), N_put_array_2d_c_value(), N_put_array_2d_d_value(), N_put_array_2d_f_value(), N_put_array_2d_value_null(), name, NULL, and 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

  array | N_array_2d *
  name | char * - the name of the raster map

Returns
  void

Definition at line 172 of file n_arrays_io.c.

References G_fatal_error(), G_free(), G_get_set_window(), G_message(), G_percent(), N_get_array_2d_c_value(), N_get_array_2d_d_value(), N_get_array_2d_f_value(), name, NULL, N_array_2d::type, 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

  array | N_array_3d *
  name | char * - the name of the volume map
  mask | int - 1 = use a 3d mask, 0 do not use a 3d mask

Returns
  void

Definition at line 381 of file n_arrays_io.c.

References G_fatal_error(), G_message(), G_percent(), N_get_array_3d_d_value(), N_get_array_3d_f_value(), name, NULL, and x.