GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
N_arrays_io.c File Reference
#include <math.h>
#include "grass/N_pde.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_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, G3d_fatalError() 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 276 of file N_arrays_io.c.

References N_array_3d::cols, dialogs::cols, menudata::data, N_array_3d::depths, G3d_closeCell(), G3d_fatalError(), G3d_getValue(), G3d_getWindow(), G3d_maskFileExists(), G3d_maskIsOff(), G3d_maskIsOn(), G3d_maskOff(), G3d_maskOn(), G3d_openCellOld(), G3d_tileTypeMap(), G_fatal_error(), G_find_grid3(), G_is_d_null_value(), G_is_f_null_value(), 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(), NULL, N_array_3d::rows, N_array_3d::type, dialogs::type, and y.

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 46 of file N_arrays_io.c.

References dialogs::cols, menudata::data, G_allocate_raster_buf(), G_close_cell(), G_fatal_error(), G_find_cell2(), G_get_raster_map_type(), G_get_raster_row(), G_get_set_window(), G_incr_void_ptr(), G_is_c_null_value(), G_is_d_null_value(), G_is_f_null_value(), G_message(), G_open_cell_old(), G_percent(), G_raster_size(), 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(), NULL, dialogs::type, and y.

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 181 of file N_arrays_io.c.

References dialogs::cols, count, G_allocate_raster_buf(), G_close_cell(), G_fatal_error(), G_get_set_window(), G_message(), G_open_raster_new(), G_percent(), G_put_c_raster_row(), G_put_d_raster_row(), G_put_f_raster_row(), G_unopen_cell(), N_get_array_2d_c_value(), N_get_array_2d_d_value(), N_get_array_2d_f_value(), NULL, N_array_2d::type, dialogs::type, and y.

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, G3d_fatalError() 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 408 of file N_arrays_io.c.

References N_array_3d::cols, dialogs::cols, count, menudata::data, N_array_3d::depths, G3d_closeCell(), G3d_fatalError(), G3d_getWindow(), G3d_maskFileExists(), G3d_maskIsOff(), G3d_maskIsOn(), G3d_maskOff(), G3d_maskOn(), G3d_openCellNew(), G3d_putDouble(), G3d_putFloat(), G_fatal_error(), G_message(), G_percent(), N_get_array_3d_d_value(), N_get_array_3d_f_value(), NULL, N_array_3d::rows, N_array_3d::type, dialogs::type, and y.