GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71790
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_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 _, RASTER3D_Region::cols, N_array_3d::cols, Cell_head::cols, DCELL_TYPE, RASTER3D_Region::depths, N_array_3d::depths, Cell_head::depths, FCELL_TYPE, 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(), NULL, Rast3d_close(), Rast3d_fatal_error(), Rast3d_get_value(), Rast3d_get_window(), Rast3d_mask_file_exists(), Rast3d_mask_is_off(), Rast3d_mask_is_on(), Rast3d_mask_off(), Rast3d_mask_on(), Rast3d_open_cell_old(), Rast3d_tile_type_map(), Rast_is_d_null_value(), Rast_is_f_null_value(), RASTER3D_DEFAULT_WINDOW, RASTER3D_TILE_SAME_AS_FILE, RASTER3D_USE_CACHE_DEFAULT, RASTER3D_Region::rows, N_array_3d::rows, Cell_head::rows, N_array_3d::type, and x.

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 _, CELL_TYPE, Cell_head::cols, DCELL_TYPE, FCELL_TYPE, G_fatal_error(), 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(), NULL, Rast_allocate_buf(), Rast_cell_size(), Rast_close(), Rast_get_map_type(), Rast_get_row(), Rast_is_c_null_value(), Rast_is_d_null_value(), Rast_is_f_null_value(), Rast_open_old(), Cell_head::rows, and x.

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_TYPE, Cell_head::cols, count, DCELL_TYPE, FCELL_TYPE, G_fatal_error(), 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(), NULL, Rast_allocate_buf(), Rast_close(), Rast_open_new(), Rast_put_c_row(), Rast_put_d_row(), Rast_put_f_row(), Cell_head::rows, N_array_2d::type, and x.

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 _, RASTER3D_Region::cols, N_array_3d::cols, Cell_head::cols, count, DCELL_TYPE, RASTER3D_Region::depths, N_array_3d::depths, Cell_head::depths, FCELL_TYPE, G_fatal_error(), G_message(), G_percent(), N_get_array_3d_d_value(), N_get_array_3d_f_value(), NULL, Rast3d_close(), Rast3d_fatal_error(), Rast3d_flush_all_tiles(), Rast3d_get_window(), Rast3d_mask_file_exists(), Rast3d_mask_is_off(), Rast3d_mask_is_on(), Rast3d_mask_off(), Rast3d_mask_on(), Rast3d_open_new_opt_tile_size(), Rast3d_put_double(), Rast3d_put_float(), RASTER3D_USE_CACHE_XY, RASTER3D_Region::rows, N_array_3d::rows, Cell_head::rows, N_array_3d::type, and x.