GRASS 8 Programmer's Manual 8.6.0dev(2026)-f6f2c534ea
Loading...
Searching...
No Matches
region.c File Reference
#include <stdio.h>
#include <math.h>
#include <grass/raster.h>
#include "raster3d_intern.h"
Include dependency graph for region.c:

Go to the source code of this file.

Functions

void Rast3d_extract2d_region (RASTER3D_Region *region3d, struct Cell_head *region2d)
 Returns in region2d the 2d portion of region3d.
 
void Rast3d_region_to_cell_head (RASTER3D_Region *region3d, struct Cell_head *region2d)
 Returns in region2d the 2d portion of region3d.
 
void Rast3d_incorporate2d_region (struct Cell_head *region2d, RASTER3D_Region *region3d)
 Replaces the 2d portion of region3d with the values stored in region2d.
 
void Rast3d_region_from_to_cell_head (struct Cell_head *region2d, RASTER3D_Region *region3d)
 Replaces the 2d portion of region3d with the values stored in region2d.
 
void Rast3d_adjust_region (RASTER3D_Region *region)
 Computes an adjusts the resolutions in the region structure from the region boundaries and number of cells per dimension.
 
void Rast3d_adjust_region_res (RASTER3D_Region *region)
 Computes an adjusts the number of cells per dimension in the region structure from the region boundaries and resolutions.
 
void Rast3d_region_copy (RASTER3D_Region *regionDest, RASTER3D_Region *regionSrc)
 Copies the values of regionSrc into regionDst.
 
int Rast3d_read_region_map (const char *name, const char *mapset, RASTER3D_Region *region)
 
int Rast3d_is_valid_location (RASTER3D_Region *region, double north, double east, double top)
 Returns 1 if region-coordinates (north, east, top) are inside the region of map. Returns 0 otherwise.
 
void Rast3d_location2coord (RASTER3D_Region *region, double north, double east, double top, int *x, int *y, int *z)
 Converts region-coordinates (north, east, top) into cell-coordinates (x, y, z).
 
void Rast3d_location2coord_double (RASTER3D_Region *region, double north, double east, double top, double *x, double *y, double *z)
 Converts region-coordinates (north, east, top) into cell-coordinates (x, y, z).
 
void Rast3d_location2coord2 (RASTER3D_Region *region, double north, double east, double top, int *x, int *y, int *z)
 Converts region-coordinates (north, east, top) into cell-coordinates (x, y, z). This function calls Rast3d_fatal_error in case location is not in window.
 
void Rast3d_coord2location (RASTER3D_Region *region, double x, double y, double z, double *north, double *east, double *top)
 Converts cell-coordinates (x, y, z) into region-coordinates (north, east, top).
 

Function Documentation

◆ Rast3d_adjust_region()

void Rast3d_adjust_region ( RASTER3D_Region region)

Computes an adjusts the resolutions in the region structure from the region boundaries and number of cells per dimension.

Parameters
region
Returns
void

Definition at line 144 of file region.c.

References RASTER3D_Region::bottom, RASTER3D_Region::depths, G_adjust_Cell_head3(), Rast3d_fatal_error(), Rast3d_region_from_to_cell_head(), Rast3d_region_to_cell_head(), RASTER3D_Region::tb_res, and RASTER3D_Region::top.

Referenced by Rast3d_fill_header(), Rast3d_open_cell_new(), Rast3d_open_cell_old(), Rast3d_set_window(), and Rast3d_set_window_map().

◆ Rast3d_adjust_region_res()

void Rast3d_adjust_region_res ( RASTER3D_Region region)

Computes an adjusts the number of cells per dimension in the region structure from the region boundaries and resolutions.

Parameters
region
Returns
void

Definition at line 168 of file region.c.

References RASTER3D_Region::bottom, RASTER3D_Region::depths, G_adjust_Cell_head3(), Rast3d_fatal_error(), Rast3d_region_from_to_cell_head(), Rast3d_region_to_cell_head(), RASTER3D_Region::tb_res, and RASTER3D_Region::top.

◆ Rast3d_coord2location()

void Rast3d_coord2location ( RASTER3D_Region region,
double  x,
double  y,
double  z,
double north,
double east,
double top 
)

Converts cell-coordinates (x, y, z) into region-coordinates (north, east, top).

  • Note: x, y and z is a double:
  • x+0.0 will return the easting for the western edge of the column.
  • x+0.5 will return the easting for the center of the column.
  • x+1.0 will return the easting for the eastern edge of the column.
  • y+0.0 will return the northing for the northern edge of the row.
  • y+0.5 will return the northing for the center of the row.
  • y+1.0 will return the northing for the southern edge of the row.
  • z+0.0 will return the top for the lower edge of the depth.
  • z+0.5 will return the top for the center of the depth.
  • z+1.0 will return the top for the upper edge of the column.
Parameters
region
x
y
z
north
east
top
Returns
void

Definition at line 374 of file region.c.

References COORD_TO_LOCATION, Cell_head::east, G_debug(), Cell_head::north, Cell_head::top, and x.

Referenced by Rast3d_nearest_neighbor().

◆ Rast3d_extract2d_region()

void Rast3d_extract2d_region ( RASTER3D_Region region3d,
struct Cell_head region2d 
)

Returns in region2d the 2d portion of region3d.

Parameters
region3d
region2d
Returns
void

Definition at line 18 of file region.c.

◆ Rast3d_incorporate2d_region()

void Rast3d_incorporate2d_region ( struct Cell_head region2d,
RASTER3D_Region region3d 
)

Replaces the 2d portion of region3d with the values stored in region2d.

Parameters
region2d
region3d
Returns
void

Definition at line 83 of file region.c.

◆ Rast3d_is_valid_location()

int Rast3d_is_valid_location ( RASTER3D_Region region,
double  north,
double  east,
double  top 
)

Returns 1 if region-coordinates (north, east, top) are inside the region of map. Returns 0 otherwise.

Parameters
region
north
east
top
Returns
int

Definition at line 249 of file region.c.

References Cell_head::bottom, RASTER3D_Region::bottom, Cell_head::east, Cell_head::north, RASTER3D_Region::south, Cell_head::top, RASTER3D_Region::top, and RASTER3D_Region::west.

Referenced by Rast3d_location2coord2().

◆ Rast3d_location2coord()

void Rast3d_location2coord ( RASTER3D_Region region,
double  north,
double  east,
double  top,
int x,
int y,
int z 
)

Converts region-coordinates (north, east, top) into cell-coordinates (x, y, z).

Parameters
region
north
east
top
x
y
z
Returns
void

Definition at line 275 of file region.c.

References Cell_head::east, LOCATION_TO_COORD, Cell_head::north, Cell_head::top, and x.

Referenced by Rast3d_get_region_value(), Rast3d_get_window_value(), and Rast3d_nearest_neighbor().

◆ Rast3d_location2coord2()

void Rast3d_location2coord2 ( RASTER3D_Region region,
double  north,
double  east,
double  top,
int x,
int y,
int z 
)

Converts region-coordinates (north, east, top) into cell-coordinates (x, y, z). This function calls Rast3d_fatal_error in case location is not in window.

Parameters
region
north
east
top
x
y
z
Returns
void

Definition at line 330 of file region.c.

References Cell_head::east, LOCATION_TO_COORD, Cell_head::north, Rast3d_fatal_error(), Rast3d_is_valid_location(), Cell_head::top, and x.

Referenced by Rast3d_get_volume_a().

◆ Rast3d_location2coord_double()

void Rast3d_location2coord_double ( RASTER3D_Region region,
double  north,
double  east,
double  top,
double x,
double y,
double z 
)

Converts region-coordinates (north, east, top) into cell-coordinates (x, y, z).

Note: The results are double numbers. Casting them to int will give the column, row and depth number.

Parameters
region
north
east
top
x
y
z
Returns
void

Definition at line 305 of file region.c.

References Cell_head::east, G_debug(), LOCATION_TO_COORD, Cell_head::north, Cell_head::top, and x.

◆ Rast3d_read_region_map()

int Rast3d_read_region_map ( const char name,
const char mapset,
RASTER3D_Region region 
)

◆ Rast3d_region_copy()

void Rast3d_region_copy ( RASTER3D_Region regionDest,
RASTER3D_Region regionSrc 
)

Copies the values of regionSrc into regionDst.

Parameters
regionDest
regionSrc
Returns
void

Definition at line 196 of file region.c.

Referenced by Rast3d_get_region_struct_map(), Rast3d_get_window(), Rast3d_getWindowStructMap(), Rast3d_open_cell_new(), Rast3d_open_cell_old(), Rast3d_set_window(), and Rast3d_set_window_map().

◆ Rast3d_region_from_to_cell_head()

void Rast3d_region_from_to_cell_head ( struct Cell_head region2d,
RASTER3D_Region region3d 
)

Replaces the 2d portion of region3d with the values stored in region2d.

Parameters
region2d
region3d
Returns
void

Definition at line 111 of file region.c.

Referenced by Rast3d_adjust_region(), and Rast3d_adjust_region_res().

◆ Rast3d_region_to_cell_head()

void Rast3d_region_to_cell_head ( RASTER3D_Region region3d,
struct Cell_head region2d 
)

Returns in region2d the 2d portion of region3d.

Parameters
region3d
region2d
Returns
void

Definition at line 45 of file region.c.

Referenced by N_init_geom_data_3d(), Rast3d_adjust_region(), and Rast3d_adjust_region_res().