[GRASS-SVN] r42944 - in grass-addons/raster/r.pi: . r.pi.corrwin
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jul 29 11:16:16 EDT 2010
Author: wegmann
Date: 2010-07-29 15:16:16 +0000 (Thu, 29 Jul 2010)
New Revision: 42944
Added:
grass-addons/raster/r.pi/r.pi.corrwin/
grass-addons/raster/r.pi/r.pi.corrwin/Makefile
grass-addons/raster/r.pi/r.pi.corrwin/bufs.c
grass-addons/raster/r.pi/r.pi.corrwin/description.html
grass-addons/raster/r.pi/r.pi.corrwin/divr_cats.c
grass-addons/raster/r.pi/r.pi.corrwin/gather.c
grass-addons/raster/r.pi/r.pi.corrwin/intr_cats.c
grass-addons/raster/r.pi/r.pi.corrwin/local_proto.h
grass-addons/raster/r.pi/r.pi.corrwin/main.c
grass-addons/raster/r.pi/r.pi.corrwin/ncb.h
grass-addons/raster/r.pi/r.pi.corrwin/null_cats.c
grass-addons/raster/r.pi/r.pi.corrwin/readcell.c
Log:
a r.pi module to compute the correlation between pixels within a moving window of two raster files. It is a merge of r.neighbours and r.covar functionality and it is the result of a first test how to program modules in GRASS - would be great if it might be useful for somebody
Added: grass-addons/raster/r.pi/r.pi.corrwin/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.corrwin/Makefile (rev 0)
+++ grass-addons/raster/r.pi/r.pi.corrwin/Makefile 2010-07-29 15:16:16 UTC (rev 42944)
@@ -0,0 +1,10 @@
+MODULE_TOPDIR = ../..
+
+PGM = r.pi.corrwin
+
+LIBES = $(STATSLIB) $(GISLIB)
+DEPENDENCIES = $(STATSDEP) $(GISDEP)
+
+include $(MODULE_TOPDIR)/include/Make/Module.make
+
+default: cmd
Property changes on: grass-addons/raster/r.pi/r.pi.corrwin/Makefile
___________________________________________________________________
Added: svn:executable
+ *
Added: grass-addons/raster/r.pi/r.pi.corrwin/bufs.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.corrwin/bufs.c (rev 0)
+++ grass-addons/raster/r.pi/r.pi.corrwin/bufs.c 2010-07-29 15:16:16 UTC (rev 42944)
@@ -0,0 +1,59 @@
+#include <grass/gis.h>
+#include "ncb.h"
+
+/*
+ allocate the i/o bufs
+
+ the i/o bufs will be rotated by the read operation so that the
+ last row read will be in the last i/o buf
+
+ */
+
+int allocate_bufs (void)
+{
+ int i;
+ int bufsize;
+
+ bufsize = (G_window_cols() + 2 * ncb.nsize) * sizeof (DCELL);
+
+ ncb.buf1 = (DCELL **) G_malloc (ncb.nsize * sizeof(DCELL *));
+ ncb.buf2 = (DCELL **) G_malloc (ncb.nsize * sizeof(DCELL *));
+ for (i = 0; i < ncb.nsize; i++)
+ {
+ ncb.buf1[i] = (DCELL *) G_malloc (bufsize) ;
+ ncb.buf2[i] = (DCELL *) G_malloc (bufsize) ;
+ G_set_d_null_value(ncb.buf1[i], G_window_cols() + 2 * ncb.nsize);
+ G_set_d_null_value(ncb.buf2[i], G_window_cols() + 2 * ncb.nsize);
+ }
+
+ return 0;
+}
+
+int rotate_bufs (int bufnumber)
+{
+ DCELL *temp;
+ int i;
+
+ if (bufnumber < 1 || bufnumber > 2)
+ return -1;
+
+ if (bufnumber == 1) {
+ temp = ncb.buf1[0];
+
+ for (i = 1; i < ncb.nsize; i++) {
+ ncb.buf1[i-1] = ncb.buf1[i];
+ }
+
+ ncb.buf1[ncb.nsize-1] = temp;
+ } else {
+ temp = ncb.buf2[0];
+
+ for (i = 1; i < ncb.nsize; i++) {
+ ncb.buf2[i-1] = ncb.buf2[i];
+ }
+
+ ncb.buf2[ncb.nsize-1] = temp;
+ }
+
+ return 0;
+}
Property changes on: grass-addons/raster/r.pi/r.pi.corrwin/bufs.c
___________________________________________________________________
Added: svn:executable
+ *
Added: grass-addons/raster/r.pi/r.pi.corrwin/description.html
===================================================================
--- grass-addons/raster/r.pi/r.pi.corrwin/description.html (rev 0)
+++ grass-addons/raster/r.pi/r.pi.corrwin/description.html 2010-07-29 15:16:16 UTC (rev 42944)
@@ -0,0 +1,94 @@
+</head>
+<body bgcolor="white">
+
+<img src="grass_logo.png" alt="GRASS logo"><hr align=center size=6 noshade>
+
+<h2>NAME</h2>
+<em><b>r.pi.corrwin</b></em> provides information concerning the correlation
+of pixels inside a moving window between two raster files.
+<h2>KEYWORDS</h2>
+raster, patch index, landscape ecology
+<h2>SYNOPSIS</h2>
+<b>r.pi.corrwin</b><br>
+<b>r.pi.corrwin help</b><br>
+<b>r.pi.corrwin</b> [-<b>a</b>] <b>input1</b>=<em>name</em>
+<b>input2</b>=<em>name</em>
+<b>output</b>=<em>name</em>
+<b>size</b>=<em>val</em> <b>max</b>=<em>name</em>
+[<b>title</b>=<em>name</em>] [--<b>overwrite</b>] [--<b>verbose</b>]
+[--<b>quiet</b>]
+
+<h3>Flags:</h3>
+<DL>
+
+<DT><b>--overwrite</b></DT>
+<DD>Allow output files to overwrite existing files</DD>
+<DT><b>--verbose</b></DT>
+<DD>Verbose module output</DD>
+<DT><b>--quiet</b></DT>
+<DD>Quiet module output</DD>
+</DL>
+
+
+<h3>Parameters:</h3>
+<DL>
+<DT><b>input1</b>=<em>name</em></DT>
+<DD>Name of an existing raster (continuous values)</DD>
+
+<DT><b>input2</b>=<em>name</em></DT>
+<DD>Name of an existing raster (continuous values)</DD>
+
+<DT><b>output</b>=<em>name</em></DT>
+<DD>Output raster map of correlation coefficient</DD>
+
+<DT><b>size</b>=<em>val</em></DT>
+<DD>The size of the moving window. Options:
+1,3,5,7,9,11,13,15,17,19,21,23,25</DD>
+
+<DT><b>max</b>=<em>value</em></DT>
+<DD>Value to be set for the correlation value 1.0 in order to receive more information of the decimal places, e.g. set it to 1000
+
+<DT><b>title</b>=<em>name</em></DT>
+<DD>Optional title of output map</DD>
+
+</DL>
+
+
+
+<H2>DESCRIPTION</H2>
+
+<P>
+This module computes the correlation between two raster files but unlike
+<EM>r.pi.lm</EM> for moving windows of a specific size. This module used code sniplets from r.neighbours and r.covar.
+
+The program will be run non-interactively if the user specifies program
+arguments (see OPTIONS) on the command
+line. Alternately, the user can simply type <B>r.pi.corrwin</B> on the command line, without program
+arguments. In this case, the user will be prompted for flag settings and parameter values.
+
+
+</DL>
+<H2>NOTES</H2>
+
+
+
+
+<P>
+
+<H2>BUGS</H2>
+
+
+
+<H2>SEE ALSO</H2>
+
+<EM><A HREF="r.pi.lm.html">r.pi.ENN</A></EM><br>
+<EM><A HREF="r.pi.probmw.html">r.pi.FNN</A></EM><br>
+<EM><A HREF="r.li.setup.html">r.li.setup</A></EM><br>
+
+<H2>AUTHOR</H2>
+Programming: Elshad Shirinov<br>
+Scientific concept: Dr. Martin Wegmann <br>
+Department of Remote Sensing <br>Remote Sensing and Biodiversity Unit<br> University of Wuerzburg, Germany
+
+
+<p><i>Last changed: $Date: 2006/04/13 19:01:37 $</i>
Property changes on: grass-addons/raster/r.pi/r.pi.corrwin/description.html
___________________________________________________________________
Added: svn:executable
+ *
Added: grass-addons/raster/r.pi/r.pi.corrwin/divr_cats.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.corrwin/divr_cats.c (rev 0)
+++ grass-addons/raster/r.pi/r.pi.corrwin/divr_cats.c 2010-07-29 15:16:16 UTC (rev 42944)
@@ -0,0 +1,9 @@
+#include <grass/gis.h>
+#include "ncb.h"
+int
+divr_cats (void)
+{
+ G_set_cats_fmt ("$1 $?different categories$category$", 1.0, 0.0, 0.0, 0.0, &ncb.cats);
+
+ return 0;
+}
Property changes on: grass-addons/raster/r.pi/r.pi.corrwin/divr_cats.c
___________________________________________________________________
Added: svn:executable
+ *
Added: grass-addons/raster/r.pi/r.pi.corrwin/gather.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.corrwin/gather.c (rev 0)
+++ grass-addons/raster/r.pi/r.pi.corrwin/gather.c 2010-07-29 15:16:16 UTC (rev 42944)
@@ -0,0 +1,39 @@
+#include <grass/gis.h>
+#include "ncb.h"
+
+/*
+ given the starting col of the neighborhood,
+ copy the cell values from the bufs into the array of values
+ and return the number of values copied.
+*/
+
+int gather(DCELL *values, int bufnumber, int offset)
+{
+ if (bufnumber < 1 || bufnumber > 2)
+ return -1;
+
+ int row, col;
+ int n = 0;
+
+ *values = 0;
+
+ for (row = 0; row < ncb.nsize; row++)
+ for (col = 0; col < ncb.nsize; col++)
+ {
+ DCELL *c;
+ if (bufnumber == 1)
+ c = &ncb.buf1[row][offset + col];
+ else
+ c = &ncb.buf2[row][offset + col];
+
+ if (G_is_d_null_value(c))
+ G_set_d_null_value(&values[n], 1);
+ else
+ values[n] = *c;
+
+ n++;
+ }
+
+ return n ? n : -1;
+}
+
Property changes on: grass-addons/raster/r.pi/r.pi.corrwin/gather.c
___________________________________________________________________
Added: svn:executable
+ *
Added: grass-addons/raster/r.pi/r.pi.corrwin/intr_cats.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.corrwin/intr_cats.c (rev 0)
+++ grass-addons/raster/r.pi/r.pi.corrwin/intr_cats.c 2010-07-29 15:16:16 UTC (rev 42944)
@@ -0,0 +1,9 @@
+#include <grass/gis.h>
+#include "ncb.h"
+
+int intr_cats (void)
+{
+ G_set_cats_fmt ("$1% dispersion", 1.0, -1.0, 0.0, 0.0, &ncb.cats);
+
+ return 0;
+}
Property changes on: grass-addons/raster/r.pi/r.pi.corrwin/intr_cats.c
___________________________________________________________________
Added: svn:executable
+ *
Added: grass-addons/raster/r.pi/r.pi.corrwin/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.corrwin/local_proto.h (rev 0)
+++ grass-addons/raster/r.pi/r.pi.corrwin/local_proto.h 2010-07-29 15:16:16 UTC (rev 42944)
@@ -0,0 +1,13 @@
+/* bufs.c */
+extern int allocate_bufs(void);
+extern int rotate_bufs(int);
+/* gather */
+extern int gather(DCELL *,int, int);
+/* readcell.c */
+extern int readcell(int, int, int, int, int);
+/* divr_cats.c */
+extern int divr_cats(void);
+/* intr_cats.c */
+extern int intr_cats(void);
+/* null_cats.c */
+extern int null_cats(void);
Property changes on: grass-addons/raster/r.pi/r.pi.corrwin/local_proto.h
___________________________________________________________________
Added: svn:executable
+ *
Added: grass-addons/raster/r.pi/r.pi.corrwin/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.corrwin/main.c (rev 0)
+++ grass-addons/raster/r.pi/r.pi.corrwin/main.c 2010-07-29 15:16:16 UTC (rev 42944)
@@ -0,0 +1,274 @@
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <grass/gis.h>
+#include <grass/glocale.h>
+#include <grass/stats.h>
+#include "ncb.h"
+#include "local_proto.h"
+#include <math.h>
+
+/*
+ Moving window correlation analyse.
+
+ Put together from pieces of r.covar and r.neighbors by Elshad Shirinov.
+*/
+
+typedef int (*ifunc)(void);
+
+struct ncb ncb;
+
+int main (int argc, char *argv[])
+{
+ char *p, *p1, *p2;
+ int verbose;
+ // in and out file pointers
+ int in_fd1, in_fd2;
+ int out_fd;
+ DCELL *result;
+
+ RASTER_MAP_TYPE map_type1, map_type2;
+
+ int row, col, i, j;
+ int readrow;
+ int maxval;
+
+ int nrows, ncols;
+ int n;
+ int copycolr;
+ struct Colors colr;
+ struct GModule *module;
+ struct
+ {
+ struct Option *input1, *input2, *output;
+ struct Option *size, *max;
+ struct Option *title;
+ } parm;
+ struct
+ {
+ struct Flag *quiet;
+ } flag;
+
+ DCELL *values1, *values2; /* list of neighborhood values */
+
+ G_gisinit (argv[0]);
+
+ module = G_define_module();
+ module->keywords = _("raster");
+ module->description =
+ _("Calculates correlation of two raster maps "
+ "by calculating correlation function of two "
+ "corresponding rectangular areas for each "
+ "raster point and writing the result into a new raster map.");
+
+ parm.input1 = G_define_option() ;
+ parm.input1->key = "input1" ;
+ parm.input1->type = TYPE_STRING ;
+ parm.input1->required = YES ;
+ parm.input1->gisprompt = "old,cell,raster,1" ;
+ parm.input1->description= _("Name of existing raster file") ;
+
+ parm.input2 = G_define_option() ;
+ parm.input2->key = "input2" ;
+ parm.input2->type = TYPE_STRING ;
+ parm.input2->required = YES ;
+ parm.input2->gisprompt = "old,cell,raster,2" ;
+ parm.input2->description= _("Name of existing raster file") ;
+
+ parm.output = G_define_option() ;
+ parm.output->key = "output" ;
+ parm.output->type = TYPE_STRING ;
+ parm.output->required = YES ;
+ parm.output->gisprompt = "new,cell,raster" ;
+ parm.output->description= _("Name of the new raster file") ;
+
+ parm.size = G_define_option() ;
+ parm.size->key = "size" ;
+ parm.size->type = TYPE_INTEGER ;
+ parm.size->required = YES ;
+ parm.size->options = "1,3,5,7,9,11,13,15,17,19,21,23,25" ;
+ parm.size->description= _("Neighborhood size") ;
+
+ parm.max = G_define_option() ;
+ parm.max->key = "max" ;
+ parm.max->type = TYPE_INTEGER ;
+ parm.max->required = YES ;
+ parm.max->description= _("Correlation maximum value") ;
+
+ parm.title = G_define_option() ;
+ parm.title->key = "title" ;
+ parm.title->key_desc = "\"phrase\"" ;
+ parm.title->type = TYPE_STRING ;
+ parm.title->required = NO ;
+ parm.title->description= _("Title of the output raster file") ;
+
+ flag.quiet = G_define_flag();
+ flag.quiet->key = 'q';
+ flag.quiet->description = _("Run quietly");
+
+ if (G_parser(argc,argv))
+ exit(1);
+
+ // get names of input files
+ p1 = ncb.oldcell1.name = parm.input1->answer;
+ p2 = ncb.oldcell2.name = parm.input2->answer;
+ // test input files existance
+ if(NULL == (ncb.oldcell1.mapset = G_find_cell2(p1,"")))
+ {
+ fprintf (stderr, "%s: <%s> raster file not found\n",
+ G_program_name(), p1);
+ exit(1);
+ }
+ if(NULL == (ncb.oldcell2.mapset = G_find_cell2(p2,"")))
+ {
+ fprintf (stderr, "%s: <%s> raster file not found\n",
+ G_program_name(), p2);
+ exit(1);
+ }
+ // check if new file name is correct
+ p = ncb.newcell.name = parm.output->answer;
+ if (G_legal_filename(p) < 0)
+ {
+ fprintf (stderr, "%s: <%s> illegal file name\n",
+ G_program_name(), p);
+ exit(1);
+ }
+ ncb.newcell.mapset = G_mapset();
+
+ // get window size
+ nrows = G_window_rows();
+ ncols = G_window_cols();
+
+ fprintf(stderr, "%d x %d ", nrows, ncols);
+
+ /* open cell files */
+ if ((in_fd1 = G_open_cell_old (ncb.oldcell1.name, ncb.oldcell1.mapset)) < 0)
+ {
+ char msg[200];
+ sprintf(msg,"can't open cell file <%s> in mapset %s\n",
+ ncb.oldcell1.name, ncb.oldcell1.mapset);
+ G_fatal_error (msg);
+ exit(-1);
+ }
+ if ((in_fd2 = G_open_cell_old (ncb.oldcell2.name, ncb.oldcell2.mapset)) < 0)
+ {
+ char msg[200];
+ sprintf(msg,"can't open cell file <%s> in mapset %s\n",
+ ncb.oldcell2.name, ncb.oldcell2.mapset);
+ G_fatal_error (msg);
+ exit(-1);
+ }
+
+ // get map types
+ map_type1 = G_raster_map_type(ncb.oldcell1.name, ncb.oldcell1.mapset);
+ map_type2 = G_raster_map_type(ncb.oldcell2.name, ncb.oldcell2.mapset);
+
+ /* copy color table? */
+ copycolr = (G_read_colors (ncb.oldcell1.name, ncb.oldcell1.mapset, &colr) > 0);
+
+ /* get the neighborhood size */
+ sscanf (parm.size->answer, "%d", &ncb.nsize);
+ ncb.dist = ncb.nsize/2;
+
+ /* get correlation maximum */
+ sscanf(parm.max->answer, "%d", &maxval);
+
+ /* allocate the cell buffers */
+ allocate_bufs ();
+ values1 = (DCELL *) G_malloc (ncb.nsize * ncb.nsize * sizeof (DCELL));
+ values2 = (DCELL *) G_malloc (ncb.nsize * ncb.nsize * sizeof (DCELL));
+ result = G_allocate_d_raster_buf();
+
+ /* get title, initialize the category and stat info */
+ if (parm.title->answer)
+ strcpy (ncb.title, parm.title->answer);
+ else
+ sprintf (ncb.title,"%dx%d neighborhood correlation: %s and %s",
+ ncb.nsize, ncb.nsize, ncb.oldcell1.name, ncb.oldcell2.name);
+
+
+ /* initialize the cell bufs with 'dist' rows of the old cellfile */
+
+ readrow = 0;
+ for (row = 0; row < ncb.dist; row++) {
+ readcell (in_fd1, 1, readrow, nrows, ncols);
+ readcell (in_fd2, 2, readrow, nrows, ncols);
+ readrow++;
+ }
+
+ /*open the new cellfile */
+ out_fd = G_open_raster_new (ncb.newcell.name, map_type1);
+ if (out_fd < 0)
+ exit(1);
+
+ if (verbose = !flag.quiet->answer)
+ fprintf (stderr, "Percent complete ... ");
+
+ for (row = 0; row < nrows; row++)
+ {
+ if (verbose)
+ G_percent (row, nrows, 2);
+ // read the next row into buffer
+ readcell (in_fd1, 1, readrow, nrows, ncols);
+ readcell (in_fd2, 2, readrow, nrows, ncols);
+ readrow++;
+ for (col = 0; col < ncols; col++)
+ {
+ DCELL sum1 = 0;
+ DCELL sum2 = 0;
+ DCELL mul, mul1, mul2;
+ mul = mul1 = mul2 = 0;
+ double count = 0;
+ DCELL ii, jj;
+
+ // set pointer to actual position in the result
+ DCELL *rp = &result[col];
+ // gather values from actual window
+ gather(values1, 1, col);
+ gather(values2, 2, col);
+ // go through all values of the window
+ for (i = 0; i < ncb.nsize * ncb.nsize; i++) {
+ // ignore values if both are nan
+ if (!(G_is_d_null_value(&values1[i]) && G_is_d_null_value(&values2[i]))) {
+ if (!G_is_d_null_value(&values1[i])) {
+ sum1 += values1[i];
+ mul1 += values1[i] * values1[i];
+ }
+ if (!G_is_d_null_value(&values2[i])) {
+ sum2 += values2[i];
+ mul2 += values2[i] * values2[i];
+ }
+ if (!G_is_d_null_value(&values1[i]) && !G_is_d_null_value(&values2[i]))
+ mul += values1[i] * values2[i];
+ // count the number of values actually processed
+ count++;
+ }
+ }
+ if (count <= 1.1) {
+ *rp = 0;
+ continue;
+ }
+ // calculate normalization
+ ii = sqrt((mul1 - sum1 * sum1 / count) / (count - 1.0));
+ jj = sqrt((mul2 - sum2 * sum2 / count) / (count - 1.0));
+
+ // set result
+ *rp = maxval * (mul - sum1 * sum2 / count) / (ii * jj * (count - 1.0));
+ if (G_is_d_null_value(rp))
+ G_set_d_null_value(rp, 1);
+ }
+ // write actual result row to the output file
+ G_put_d_raster_row(out_fd, result);
+ }
+ if (verbose)
+ G_percent (row, nrows, 2);
+
+ G_close_cell (out_fd);
+ G_close_cell (in_fd1);
+ G_close_cell (in_fd2);
+
+ if(copycolr)
+ G_write_colors (ncb.newcell.name, ncb.newcell.mapset, &colr);
+
+ exit(0);
+}
Property changes on: grass-addons/raster/r.pi/r.pi.corrwin/main.c
___________________________________________________________________
Added: svn:executable
+ *
Added: grass-addons/raster/r.pi/r.pi.corrwin/ncb.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.corrwin/ncb.h (rev 0)
+++ grass-addons/raster/r.pi/r.pi.corrwin/ncb.h 2010-07-29 15:16:16 UTC (rev 42944)
@@ -0,0 +1,20 @@
+
+struct ncb /* neighborhood control block */
+{
+ DCELL **buf1, **buf2; /* for reading cell file */
+ int *value; /* neighborhood values */
+ int nsize; /* size of the neighborhood */
+ int dist; /* nsize/2 */
+ struct Categories cats;
+ char title[1024];
+ FILE *out;
+ struct
+ {
+ char *name;
+ char *mapset;
+ }
+ oldcell1, oldcell2, newcell;
+};
+
+extern struct ncb ncb;
+
Property changes on: grass-addons/raster/r.pi/r.pi.corrwin/ncb.h
___________________________________________________________________
Added: svn:executable
+ *
Added: grass-addons/raster/r.pi/r.pi.corrwin/null_cats.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.corrwin/null_cats.c (rev 0)
+++ grass-addons/raster/r.pi/r.pi.corrwin/null_cats.c 2010-07-29 15:16:16 UTC (rev 42944)
@@ -0,0 +1,12 @@
+#include <grass/gis.h>
+#include "ncb.h"
+
+int null_cats (void)
+{
+ int ncats;
+
+ ncats = G_number_of_cats (ncb.newcell.name, ncb.newcell.mapset);
+ G_init_cats (ncats, ncb.title, &ncb.cats);
+
+ return 0;
+}
Property changes on: grass-addons/raster/r.pi/r.pi.corrwin/null_cats.c
___________________________________________________________________
Added: svn:executable
+ *
Added: grass-addons/raster/r.pi/r.pi.corrwin/readcell.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.corrwin/readcell.c (rev 0)
+++ grass-addons/raster/r.pi/r.pi.corrwin/readcell.c 2010-07-29 15:16:16 UTC (rev 42944)
@@ -0,0 +1,28 @@
+#include <unistd.h>
+#include <grass/gis.h>
+#include "ncb.h"
+#include "local_proto.h"
+
+int readcell (int fd, int bufnumber, int row, int nrows, int ncols)
+{
+ if (bufnumber < 1 || bufnumber > 2)
+ return -1;
+
+ if (bufnumber == 1)
+ rotate_bufs(1);
+ else
+ rotate_bufs(2);
+
+ if (row < nrows)
+ if (bufnumber == 1)
+ G_get_d_raster_row (fd, ncb.buf1[ncb.nsize-1] + ncb.dist, row);
+ else
+ G_get_d_raster_row (fd, ncb.buf2[ncb.nsize-1] + ncb.dist, row);
+ else
+ if (bufnumber == 1)
+ G_set_d_null_value(ncb.buf1[ncb.nsize-1] + ncb.dist, ncols);
+ else
+ G_set_d_null_value(ncb.buf2[ncb.nsize-1] + ncb.dist, ncols);
+
+ return 0;
+}
Property changes on: grass-addons/raster/r.pi/r.pi.corrwin/readcell.c
___________________________________________________________________
Added: svn:executable
+ *
More information about the grass-commit
mailing list