GRASS GIS 8 Programmer's Manual  8.4.0dev(2024)-535c39c9fc
raster/window.c File Reference

Raster Library - Window functions. More...

#include <grass/gis.h>
#include <grass/raster.h>
#include <grass/glocale.h>
#include "R.h"
Include dependency graph for raster/window.c:

Go to the source code of this file.

Functions

void Rast_get_window (struct Cell_head *window)
 Read the current window. More...
 
void Rast_get_input_window (struct Cell_head *window)
 Read the current input window. More...
 
void Rast_get_output_window (struct Cell_head *window)
 Read the current output window. More...
 
int Rast_window_rows (void)
 Number of rows in active window. More...
 
int Rast_window_cols (void)
 Number of columns in active window. More...
 
int Rast_input_window_rows (void)
 Number of rows in active input window. More...
 
int Rast_input_window_cols (void)
 Number of columns in active input window. More...
 
int Rast_output_window_rows (void)
 Number of rows in active output window. More...
 
int Rast_output_window_cols (void)
 Number of columns in active output window. More...
 
double Rast_northing_to_row (double north, const struct Cell_head *window)
 Northing to row. More...
 
double Rast_easting_to_col (double east, const struct Cell_head *window)
 Easting to column. More...
 
double Rast_row_to_northing (double row, const struct Cell_head *window)
 Row to northing. More...
 
double Rast_col_to_easting (double col, const struct Cell_head *window)
 Column to easting. More...
 

Detailed Description

Raster Library - Window functions.

(C) 2001-2009 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
Original author CERL

Definition in file raster/window.c.

Function Documentation

◆ Rast_col_to_easting()

double Rast_col_to_easting ( double  col,
const struct Cell_head window 
)

Column to easting.

Converts a col relative to a window to an easting.

Note: col is a double:

  • col+0.0 will return the easting for the western edge of the column.
  • col+0.5 will return the easting for the center of the column.
  • col+1.0 will return the easting for the eastern edge of the column.
Parameters
colcolumn number
[in]windowpointer to Cell_head
Returns
east coordinate

Definition at line 269 of file raster/window.c.

◆ Rast_easting_to_col()

double Rast_easting_to_col ( double  east,
const struct Cell_head window 
)

Easting to column.

Converts east relative to a window to a column.

Note: The result is a double. Casting it to an int will give the column number.

Parameters
easteast coordinate
windowpointer to Cell_head
Returns
column number

Definition at line 226 of file raster/window.c.

◆ Rast_get_input_window()

void Rast_get_input_window ( struct Cell_head window)

Read the current input window.

Parameters
windowpointer to Cell_head

Definition at line 45 of file raster/window.c.

◆ Rast_get_output_window()

void Rast_get_output_window ( struct Cell_head window)

Read the current output window.

Parameters
windowpointer to Cell_head

Definition at line 58 of file raster/window.c.

◆ Rast_get_window()

void Rast_get_window ( struct Cell_head window)

Read the current window.

Parameters
windowpointer to Cell_head

Definition at line 26 of file raster/window.c.

◆ Rast_input_window_cols()

int Rast_input_window_cols ( void  )

Number of columns in active input window.

This routine returns the number of columns in the active input window.

Returns
number of columns

Definition at line 158 of file raster/window.c.

References Cell_head::cols, Rast__init_window(), and R__::rd_window.

Referenced by Rast_allocate_c_input_buf(), Rast_allocate_d_input_buf(), Rast_allocate_f_input_buf(), Rast_allocate_input_buf(), Rast_allocate_null_input_buf(), and Rast_zero_input_buf().

◆ Rast_input_window_rows()

int Rast_input_window_rows ( void  )

Number of rows in active input window.

This routine returns the number of rows in the active input window.

Returns
number of rows

Definition at line 144 of file raster/window.c.

References Rast__init_window(), R__::rd_window, and Cell_head::rows.

◆ Rast_northing_to_row()

double Rast_northing_to_row ( double  north,
const struct Cell_head window 
)

Northing to row.

Converts a northing relative to a window to a row.

Note: The result is a double. Casting it to an integer will give the row number.

Parameters
northnorthing value
windowpointer to Cell_head
Returns
row number

Definition at line 207 of file raster/window.c.

◆ Rast_output_window_cols()

int Rast_output_window_cols ( void  )

Number of columns in active output window.

This routine returns the number of columns in the active output window.

Returns
number of columns

Definition at line 186 of file raster/window.c.

References Cell_head::cols, Rast__init_window(), and R__::wr_window.

Referenced by Rast_allocate_c_output_buf(), Rast_allocate_d_output_buf(), Rast_allocate_f_output_buf(), Rast_allocate_null_output_buf(), Rast_allocate_output_buf(), and Rast_zero_output_buf().

◆ Rast_output_window_rows()

int Rast_output_window_rows ( void  )

Number of rows in active output window.

This routine returns the number of rows in the active output window.

Returns
number of rows

Definition at line 172 of file raster/window.c.

References Rast__init_window(), Cell_head::rows, and R__::wr_window.

◆ Rast_row_to_northing()

double Rast_row_to_northing ( double  row,
const struct Cell_head window 
)

Row to northing.

Converts a row relative to a window to a northing.

Note: row is a double:

  • row+0.0 will return the northing for the northern edge of the row.
  • row+0.5 will return the northing for the center of the row.
  • row+1.0 will return the northing for the southern edge of the row.
Parameters
rowrow number
[in]windowpointer to Cell_head
Returns
north coordinate

Definition at line 249 of file raster/window.c.

◆ Rast_window_cols()

int Rast_window_cols ( void  )

Number of columns in active window.

These routines return the number of rows and columns (respectively) in the active module region. Before raster maps can be read or written, it is necessary to known how many rows and columns are in the active region. For example:

int nrows, cols;
int row, col;
nrows = Rast_window_rows();
ncols = Rast_window_cols();
for (row = 0; row < nrows; row++) {
// read row ...
for (col = 0; col < ncols; col++) {
// process col ...
}
}
int Rast_window_cols(void)
Number of columns in active window.
int Rast_window_rows(void)
Number of rows in active window.
Definition: raster/window.c:87
Returns
number of columns

Definition at line 124 of file raster/window.c.

References _, Cell_head::cols, G_fatal_error(), Rast__init_window(), R__::split_window, and R__::wr_window.

Referenced by Rast_allocate_buf(), Rast_allocate_c_buf(), Rast_allocate_d_buf(), Rast_allocate_f_buf(), Rast_allocate_null_buf(), and Rast_zero_buf().

◆ Rast_window_rows()

int Rast_window_rows ( void  )

Number of rows in active window.

This routine returns the number of rows in the active module window. Before raster files can be read or written, it is necessary to known how many rows are in the active window. For example:

int nrows, cols;
int row, col;
nrows = Rast_window_rows();
ncols = Rast_window_cols();
for (row = 0; row < nrows; row++) {
// read row ...
for (col = 0; col < ncols; col++) {
// process col ...
}
}
Returns
number of rows

Definition at line 87 of file raster/window.c.

References _, G_fatal_error(), Rast__init_window(), Cell_head::rows, R__::split_window, and R__::wr_window.