[GRASS-SVN] r47449 - in grass-addons/grass7/imagery: . i.topo.corr
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Aug 4 13:23:41 EDT 2011
Author: neteler
Date: 2011-08-04 10:23:41 -0700 (Thu, 04 Aug 2011)
New Revision: 47449
Added:
grass-addons/grass7/imagery/i.topo.corr/
Modified:
grass-addons/grass7/imagery/i.topo.corr/Makefile
grass-addons/grass7/imagery/i.topo.corr/correction.c
grass-addons/grass7/imagery/i.topo.corr/illumination.c
grass-addons/grass7/imagery/i.topo.corr/local_proto.h
grass-addons/grass7/imagery/i.topo.corr/main.c
grass-addons/grass7/imagery/i.topo.corr/test_i.topo.corr_synthetic_DEM_NC.sh
Log:
almost ported to GRASS 7
Modified: grass-addons/grass7/imagery/i.topo.corr/Makefile
===================================================================
--- grass-addons/imagery/i.topo.corr/Makefile 2011-08-04 15:37:24 UTC (rev 47448)
+++ grass-addons/grass7/imagery/i.topo.corr/Makefile 2011-08-04 17:23:41 UTC (rev 47449)
@@ -2,8 +2,8 @@
PGM = i.topo.corr
-LIBES = $(GISLIB)
-DEPENDENCIES = $(GISDEP)
+LIBES = $(GISLIB) $(RASTERLIB)
+DEPENDENCIES = $(GISDEP) $(RASTERDEP)
include $(MODULE_TOPDIR)/include/Make/Module.make
Modified: grass-addons/grass7/imagery/i.topo.corr/correction.c
===================================================================
--- grass-addons/imagery/i.topo.corr/correction.c 2011-08-04 15:37:24 UTC (rev 47448)
+++ grass-addons/grass7/imagery/i.topo.corr/correction.c 2011-08-04 17:23:41 UTC (rev 47449)
@@ -13,6 +13,7 @@
#include <math.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/raster.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -28,8 +29,8 @@
double a, m, cka, ckb, kk;
- nrows = G_window_rows();
- ncols = G_window_cols();
+ nrows = Rast_window_rows();
+ ncols = Rast_window_cols();
cos_z = cos(D2R * zenith);
@@ -39,8 +40,8 @@
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
- G_get_raster_row(band->fd, band->rast, row, DCELL_TYPE);
- G_get_raster_row(cosi->fd, cosi->rast, row, cosi->type);
+ Rast_get_row(band->fd, band->rast, row, DCELL_TYPE);
+ Rast_get_row(cosi->fd, cosi->rast, row, cosi->type);
for (col = 0; col < ncols; col++) {
switch (cosi->type) {
@@ -59,8 +60,8 @@
}
pref = (void *)((DCELL *) band->rast + col);
- if (!G_is_null_value(pref, DCELL_TYPE) &&
- !G_is_null_value(pcos, cosi->type)) {
+ if (!Rast_is_null_value(pref, DCELL_TYPE) &&
+ !Rast_is_null_value(pcos, cosi->type)) {
ref_i = (double)*((DCELL *) pref);
switch (method) {
case MINNAERT:
@@ -117,8 +118,8 @@
for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 2);
- G_get_raster_row(band->fd, band->rast, row, band->type);
- G_get_raster_row(cosi->fd, cosi->rast, row, cosi->type);
+ Rast_get_row(band->fd, band->rast, row, band->type);
+ Rast_get_row(cosi->fd, cosi->rast, row, cosi->type);
for (col = 0; col < ncols; col++) {
switch (cosi->type) {
@@ -138,9 +139,9 @@
pref = (void *)((DCELL *) band->rast + col);
if (pcos == NULL ||
- G_is_null_value(pref, DCELL_TYPE) ||
- G_is_null_value(pcos, cosi->type)) {
- G_set_null_value((DCELL *) out->rast + col, 1, DCELL_TYPE);
+ Rast_is_null_value(pref, DCELL_TYPE) ||
+ Rast_is_null_value(pcos, cosi->type)) {
+ Rast_set_null_value((DCELL *) out->rast + col, 1, DCELL_TYPE);
}
else {
ref_i = (double)*((DCELL *) pref);
@@ -152,6 +153,6 @@
((DCELL *) out->rast)[col]);
}
}
- G_put_raster_row(out->fd, out->rast, out->type);
+ Rast_put_row(out->fd, out->rast, out->type);
}
}
Modified: grass-addons/grass7/imagery/i.topo.corr/illumination.c
===================================================================
--- grass-addons/imagery/i.topo.corr/illumination.c 2011-08-04 15:37:24 UTC (rev 47448)
+++ grass-addons/grass7/imagery/i.topo.corr/illumination.c 2011-08-04 17:23:41 UTC (rev 47449)
@@ -13,6 +13,7 @@
#include <math.h>
#include <unistd.h>
#include <grass/gis.h>
+#include <grass/raster.h>
#include <grass/glocale.h>
#include "local_proto.h"
@@ -30,11 +31,11 @@
G_get_set_window(&window);
G_begin_distance_calculations();
- north = G_row_to_northing(0.5, &window);
- center = G_row_to_northing(1.5, &window);
- south = G_row_to_northing(2.5, &window);
- east = G_col_to_easting(2.5, &window);
- west = G_col_to_easting(0.5, &window);
+ north = Rast_row_to_northing(0.5, &window);
+ center = Rast_row_to_northing(1.5, &window);
+ south = Rast_row_to_northing(2.5, &window);
+ east = Rast_col_to_easting(2.5, &window);
+ west = Rast_col_to_easting(0.5, &window);
V = G_distance(east, north, east, south) * 4;
H = G_distance(east, center, west, center) * 4;
@@ -45,19 +46,19 @@
sin_z = sin(zenith);
/* Making cos_i raster ... */
- nrows = G_window_rows();
- ncols = G_window_cols();
+ nrows = Rast_window_rows();
+ ncols = Rast_window_cols();
cell[0] = (CELL *) G_calloc(ncols + 1, sizeof(CELL));
- G_set_c_null_value(cell[0], ncols);
+ Rast_set_c_null_value(cell[0], ncols);
cell[1] = (CELL *) G_calloc(ncols + 1, sizeof(CELL));
- G_set_c_null_value(cell[1], ncols);
+ Rast_set_c_null_value(cell[1], ncols);
cell[2] = (CELL *) G_calloc(ncols + 1, sizeof(CELL));
- G_set_c_null_value(cell[2], ncols);
+ Rast_set_c_null_value(cell[2], ncols);
/* First row is null */
- G_set_null_value((DCELL *) out->rast, G_window_cols(), DCELL_TYPE);
- G_put_raster_row(out->fd, out->rast, DCELL_TYPE);
+ Rast_set_null_value((DCELL *) out->rast, Rast_window_cols(), DCELL_TYPE);
+ Rast_put_row(out->fd, out->rast, DCELL_TYPE);
/* Next rows ... */
for (row = 2; row < nrows; row++) {
G_percent(row, nrows, 2);
@@ -65,7 +66,7 @@
cell[0] = cell[1];
cell[1] = cell[2];
cell[2] = temp;
- G_get_c_raster_row_nomask(dem->fd, cell[2], row);
+ Rast_get_c_row_nomask(dem->fd, cell[2], row);
c1 = cell[0];
c2 = c1 + 1;
@@ -79,12 +80,12 @@
for (col = 1; col < ncols - 1;
col++, c1++, c2++, c3++, c4++, c5++, c6++, c7++, c8++, c9++) {
- if (G_is_c_null_value(c1) || G_is_c_null_value(c2) ||
- G_is_c_null_value(c3) || G_is_c_null_value(c4) ||
- G_is_c_null_value(c5) || G_is_c_null_value(c6) ||
- G_is_c_null_value(c7) || G_is_c_null_value(c8) ||
- G_is_c_null_value(c9)) {
- G_set_d_null_value((DCELL *) out->rast + col, 1);
+ if (Rast_is_c_null_value(c1) || Rast_is_c_null_value(c2) ||
+ Rast_is_c_null_value(c3) || Rast_is_c_null_value(c4) ||
+ Rast_is_c_null_value(c5) || Rast_is_c_null_value(c6) ||
+ Rast_is_c_null_value(c7) || Rast_is_c_null_value(c8) ||
+ Rast_is_c_null_value(c9)) {
+ Rast_set_d_null_value((DCELL *) out->rast + col, 1);
}
else {
dx = ((*c1 + *c4 + *c4 + *c7) - (*c3 + *c6 + *c6 + *c9)) / H;
@@ -103,11 +104,11 @@
}
}
- G_put_raster_row(out->fd, out->rast, DCELL_TYPE);
+ Rast_put_row(out->fd, out->rast, DCELL_TYPE);
}
/* Last row is null */
- G_set_null_value((DCELL *) out->rast, G_window_cols(), DCELL_TYPE);
- G_put_raster_row(out->fd, out->rast, DCELL_TYPE);
+ Rast_set_null_value((DCELL *) out->rast, Rast_window_cols(), DCELL_TYPE);
+ Rast_put_row(out->fd, out->rast, DCELL_TYPE);
}
void eval_f_cosi(Gfile * out, Gfile * dem, double zenith, double azimuth)
@@ -123,11 +124,11 @@
G_get_set_window(&window);
G_begin_distance_calculations();
- north = G_row_to_northing(0.5, &window);
- center = G_row_to_northing(1.5, &window);
- south = G_row_to_northing(2.5, &window);
- east = G_col_to_easting(2.5, &window);
- west = G_col_to_easting(0.5, &window);
+ north = Rast_row_to_northing(0.5, &window);
+ center = Rast_row_to_northing(1.5, &window);
+ south = Rast_row_to_northing(2.5, &window);
+ east = Rast_col_to_easting(2.5, &window);
+ west = Rast_col_to_easting(0.5, &window);
V = G_distance(east, north, east, south) * 4;
H = G_distance(east, center, west, center) * 4;
@@ -138,19 +139,19 @@
sin_z = sin(zenith);
/* Making cos_i raster ... */
- nrows = G_window_rows();
- ncols = G_window_cols();
+ nrows = Rast_window_rows();
+ ncols = Rast_window_cols();
cell[0] = (FCELL *) G_calloc(ncols + 1, sizeof(FCELL));
- G_set_f_null_value(cell[0], ncols);
+ Rast_set_f_null_value(cell[0], ncols);
cell[1] = (FCELL *) G_calloc(ncols + 1, sizeof(FCELL));
- G_set_f_null_value(cell[1], ncols);
+ Rast_set_f_null_value(cell[1], ncols);
cell[2] = (FCELL *) G_calloc(ncols + 1, sizeof(FCELL));
- G_set_f_null_value(cell[2], ncols);
+ Rast_set_f_null_value(cell[2], ncols);
/* First row is null */
- G_set_null_value((DCELL *) out->rast, G_window_cols(), DCELL_TYPE);
- G_put_raster_row(out->fd, out->rast, DCELL_TYPE);
+ Rast_set_null_value((DCELL *) out->rast, Rast_window_cols(), DCELL_TYPE);
+ Rast_put_row(out->fd, out->rast, DCELL_TYPE);
/* Next rows ... */
for (row = 2; row < nrows; row++) {
G_percent(row, nrows, 2);
@@ -158,7 +159,7 @@
cell[0] = cell[1];
cell[1] = cell[2];
cell[2] = temp;
- G_get_f_raster_row_nomask(dem->fd, cell[2], row);
+ Rast_get_f_row_nomask(dem->fd, cell[2], row);
c1 = cell[0];
c2 = c1 + 1;
@@ -172,12 +173,12 @@
for (col = 1; col < ncols - 1;
col++, c1++, c2++, c3++, c4++, c5++, c6++, c7++, c8++, c9++) {
- if (G_is_f_null_value(c1) || G_is_f_null_value(c2) ||
- G_is_f_null_value(c3) || G_is_f_null_value(c4) ||
- G_is_f_null_value(c5) || G_is_f_null_value(c6) ||
- G_is_f_null_value(c7) || G_is_f_null_value(c8) ||
- G_is_f_null_value(c9)) {
- G_set_d_null_value((DCELL *) out->rast + col, 1);
+ if (Rast_is_f_null_value(c1) || Rast_is_f_null_value(c2) ||
+ Rast_is_f_null_value(c3) || Rast_is_f_null_value(c4) ||
+ Rast_is_f_null_value(c5) || Rast_is_f_null_value(c6) ||
+ Rast_is_f_null_value(c7) || Rast_is_f_null_value(c8) ||
+ Rast_is_f_null_value(c9)) {
+ Rast_set_d_null_value((DCELL *) out->rast + col, 1);
}
else {
dx = ((*c1 + *c4 + *c4 + *c7) - (*c3 + *c6 + *c6 + *c9)) / H;
@@ -196,11 +197,11 @@
}
}
- G_put_raster_row(out->fd, out->rast, DCELL_TYPE);
+ Rast_put_row(out->fd, out->rast, DCELL_TYPE);
}
/* Last row is null */
- G_set_null_value((DCELL *) out->rast, G_window_cols(), DCELL_TYPE);
- G_put_raster_row(out->fd, out->rast, DCELL_TYPE);
+ Rast_set_null_value((DCELL *) out->rast, Rast_window_cols(), DCELL_TYPE);
+ Rast_put_row(out->fd, out->rast, DCELL_TYPE);
}
void eval_d_cosi(Gfile * out, Gfile * dem, double zenith, double azimuth)
@@ -216,11 +217,11 @@
G_get_set_window(&window);
G_begin_distance_calculations();
- north = G_row_to_northing(0.5, &window);
- center = G_row_to_northing(1.5, &window);
- south = G_row_to_northing(2.5, &window);
- east = G_col_to_easting(2.5, &window);
- west = G_col_to_easting(0.5, &window);
+ north = Rast_row_to_northing(0.5, &window);
+ center = Rast_row_to_northing(1.5, &window);
+ south = Rast_row_to_northing(2.5, &window);
+ east = Rast_col_to_easting(2.5, &window);
+ west = Rast_col_to_easting(0.5, &window);
V = G_distance(east, north, east, south) * 4;
H = G_distance(east, center, west, center) * 4;
@@ -231,19 +232,19 @@
sin_z = sin(zenith);
/* Making cos_i raster ... */
- nrows = G_window_rows();
- ncols = G_window_cols();
+ nrows = Rast_window_rows();
+ ncols = Rast_window_cols();
cell[0] = (DCELL *) G_calloc(ncols + 1, sizeof(DCELL));
- G_set_d_null_value(cell[0], ncols);
+ Rast_set_d_null_value(cell[0], ncols);
cell[1] = (DCELL *) G_calloc(ncols + 1, sizeof(DCELL));
- G_set_d_null_value(cell[1], ncols);
+ Rast_set_d_null_value(cell[1], ncols);
cell[2] = (DCELL *) G_calloc(ncols + 1, sizeof(DCELL));
- G_set_d_null_value(cell[2], ncols);
+ Rast_set_d_null_value(cell[2], ncols);
/* First row is null */
- G_set_null_value((DCELL *) out->rast, G_window_cols(), DCELL_TYPE);
- G_put_raster_row(out->fd, out->rast, DCELL_TYPE);
+ Rast_set_null_value((DCELL *) out->rast, Rast_window_cols(), DCELL_TYPE);
+ Rast_put_row(out->fd, out->rast, DCELL_TYPE);
/* Next rows ... */
for (row = 2; row < nrows; row++) {
G_percent(row, nrows, 2);
@@ -251,7 +252,7 @@
cell[0] = cell[1];
cell[1] = cell[2];
cell[2] = temp;
- G_get_d_raster_row_nomask(dem->fd, cell[2], row);
+ Rast_get_d_row_nomask(dem->fd, cell[2], row);
c1 = cell[0];
c2 = c1 + 1;
@@ -265,12 +266,12 @@
for (col = 1; col < ncols - 1;
col++, c1++, c2++, c3++, c4++, c5++, c6++, c7++, c8++, c9++) {
- if (G_is_d_null_value(c1) || G_is_d_null_value(c2) ||
- G_is_d_null_value(c3) || G_is_d_null_value(c4) ||
- G_is_d_null_value(c5) || G_is_d_null_value(c6) ||
- G_is_d_null_value(c7) || G_is_d_null_value(c8) ||
- G_is_d_null_value(c9)) {
- G_set_d_null_value((DCELL *) out->rast + col, 1);
+ if (Rast_is_d_null_value(c1) || Rast_is_d_null_value(c2) ||
+ Rast_is_d_null_value(c3) || Rast_is_d_null_value(c4) ||
+ Rast_is_d_null_value(c5) || Rast_is_d_null_value(c6) ||
+ Rast_is_d_null_value(c7) || Rast_is_d_null_value(c8) ||
+ Rast_is_d_null_value(c9)) {
+ Rast_set_d_null_value((DCELL *) out->rast + col, 1);
}
else {
dx = ((*c1 + *c4 + *c4 + *c7) - (*c3 + *c6 + *c6 + *c9)) / H;
@@ -289,9 +290,10 @@
}
}
- G_put_raster_row(out->fd, out->rast, DCELL_TYPE);
+ Rast_put_row(out->fd, out->rast, DCELL_TYPE);
}
/* Last row is null */
- G_set_null_value((DCELL *) out->rast, G_window_cols(), DCELL_TYPE);
- G_put_raster_row(out->fd, out->rast, DCELL_TYPE);
+ Rast_set_null_value((DCELL *) out->rast, Rast_window_cols(), DCELL_TYPE);
+ Rast_put_row(out->fd, out->rast, DCELL_TYPE);
}
+
Modified: grass-addons/grass7/imagery/i.topo.corr/local_proto.h
===================================================================
--- grass-addons/imagery/i.topo.corr/local_proto.h 2011-08-04 15:37:24 UTC (rev 47448)
+++ grass-addons/grass7/imagery/i.topo.corr/local_proto.h 2011-08-04 17:23:41 UTC (rev 47449)
@@ -1,3 +1,5 @@
+#include <grass/raster.h>
+
#ifndef _LOCAL_PROTO_H
#define _LOCAL_PROTO_H
@@ -8,7 +10,7 @@
typedef struct
{
int fd;
- char name[128];
+ char name[GNAME_MAX];
char *mapset;
void *rast;
RASTER_MAP_TYPE type;
Modified: grass-addons/grass7/imagery/i.topo.corr/main.c
===================================================================
--- grass-addons/imagery/i.topo.corr/main.c 2011-08-04 15:37:24 UTC (rev 47448)
+++ grass-addons/grass7/imagery/i.topo.corr/main.c 2011-08-04 17:23:41 UTC (rev 47449)
@@ -18,48 +18,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <grass/gis.h>
+#include <grass/raster.h>
#include <grass/glocale.h>
#include "local_proto.h"
-int full_open_old(Gfile * gf, char *fname)
-{
- gf->fd = -1;
-
- snprintf(gf->name, 127, "%s", fname);
-
- gf->mapset = G_find_cell2(gf->name, "");
- if (gf->mapset == NULL)
- G_fatal_error("Cell file <%s> not found", gf->name);
-
- gf->fd = G_open_cell_old(gf->name, gf->mapset);
- if (gf->fd < 0)
- G_fatal_error(_("Cannot open file [%s] in mapset [%s]"), gf->name,
- gf->mapset);
-
- gf->type = G_raster_map_type(gf->name, gf->mapset);
-
- return gf->fd;
-}
-
-int full_open_new(Gfile * gf, char *fname, RASTER_MAP_TYPE ftype)
-{
- gf->fd = -1;
-
- snprintf(gf->name, 127, "%s", fname);
- if (G_legal_filename(gf->name) < 0)
- G_fatal_error(_("<%s> is an illegal name"), gf->name);
-
- gf->type = ftype;
- gf->mapset = G_mapset();
- gf->fd = G_open_raster_new(gf->name, gf->type);
- if (gf->fd < 0)
- G_fatal_error(_("Cannot create file <%s> in mapset <%s>"), gf->name,
- gf->mapset);
-
- return gf->fd;
-}
-
int main(int argc, char *argv[])
{
struct History history;
@@ -81,9 +44,10 @@
/* initialize module */
module = G_define_module();
+ G_add_keyword(_("raster"));
+ G_add_keyword(_("terrain"));
+ G_add_keyword(_("topographic correction"));
module->description = _("Topografic correction of reflectance");
- module->keywords =
- _("Topographic correction, Cosine, Minnaert, C-Factor, Percent");
/* It defines the different parameters */
@@ -156,26 +120,26 @@
if (ilum->answer) {
azimuth = atof(azim->answer);
/* Warning: make buffers and output after set window */
- full_open_old(&dem, base->answer);
+ dem.fd = Rast_open_old(base->answer, "");
/* Set window to DEM file */
- G_get_window(&window);
- G_get_cellhd(dem.name, dem.mapset, &hd_dem);
- G_align_window(&window, &hd_dem);
- G_set_window(&window);
+ Rast_get_window(&window);
+ Rast_get_cellhd(dem.name, "", &hd_dem);
+ Rast_align_window(&window, &hd_dem);
+ Rast_set_window(&window);
/* Open and buffer of the output file */
- full_open_new(&out, output->answer, DCELL_TYPE);
- out.rast = G_allocate_raster_buf(out.type);
+ out.fd = Rast_open_new(output->answer, DCELL_TYPE);
+ out.rast = Rast_allocate_buf(out.type);
/* Open and buffer of the elevation file */
if (dem.type == CELL_TYPE) {
- dem.rast = G_allocate_raster_buf(CELL_TYPE);
+ dem.rast = Rast_allocate_buf(CELL_TYPE);
eval_c_cosi(&out, &dem, zenith, azimuth);
}
else if (dem.type == FCELL_TYPE) {
- dem.rast = G_allocate_raster_buf(FCELL_TYPE);
+ dem.rast = Rast_allocate_buf(FCELL_TYPE);
eval_f_cosi(&out, &dem, zenith, azimuth);
}
else if (dem.type == DCELL_TYPE) {
- dem.rast = G_allocate_raster_buf(DCELL_TYPE);
+ dem.rast = Rast_allocate_buf(DCELL_TYPE);
eval_d_cosi(&out, &dem, zenith, azimuth);
}
else {
@@ -183,12 +147,12 @@
}
/* Close files, buffers, and write history */
G_free(dem.rast);
- G_close_cell(dem.fd);
+ Rast_close(dem.fd);
G_free(out.rast);
- G_close_cell(out.fd);
- G_short_history(out.name, "raster", &history);
- G_command_history(&history);
- G_write_history(out.name, &history);
+ Rast_close(out.fd);
+ Rast_short_history(out.name, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(out.name, &history);
}
/* Evaluate topographic correction for all bands */
/* i.topo.corr input=on07.toar.1 out=tcor base=cosi.on07 zenith=33.3631 method=c-factor */
@@ -211,40 +175,40 @@
else
G_fatal_error(_("Invalid method: %s"), metho->answer);
- full_open_old(&dem, base->answer);
+ dem.fd = Rast_open_old(base->answer, "");
if (dem.type == CELL_TYPE)
G_fatal_error(_("Illumination model is of CELL type"));
for (i = 0; input->answers[i] != NULL; i++) {
G_message("\nBand %s: ", input->answers[i]);
/* Abre fichero de bandas y el de salida */
- full_open_old(&band, input->answers[i]);
+ band.fd = Rast_open_old(input->answers[i], "");
if (band.type != DCELL_TYPE) {
G_warning(_("Reflectance of <%s> is not of DCELL type - ignored."),
input->answers[i]);
- G_close_cell(band.fd);
+ Rast_close(band.fd);
continue;
}
- G_get_cellhd(band.name, band.mapset, &hd_band);
- G_set_window(&hd_band); /* Antes de out_open y allocate para mismo tamaño */
+ Rast_get_cellhd(band.name, band.mapset, &hd_band);
+ Rast_set_window(&hd_band); /* Antes de out_open y allocate para mismo tamaño */
/* ----- */
snprintf(bufname, 127, "%s.%s", output->answer,
input->answers[i]);
- full_open_new(&out, bufname, DCELL_TYPE);
- out.rast = G_allocate_raster_buf(out.type);
- band.rast = G_allocate_raster_buf(band.type);
- dem.rast = G_allocate_raster_buf(dem.type);
+ out.fd = Rast_open_new(bufname, DCELL_TYPE);
+ out.rast = Rast_allocate_buf(out.type);
+ band.rast = Rast_allocate_buf(band.type);
+ dem.rast = Rast_allocate_buf(dem.type);
/* ----- */
eval_tcor(method, &out, &dem, &band, zenith);
/* ----- */
G_free(dem.rast);
G_free(band.rast);
- G_close_cell(band.fd);
+ Rast_close(band.fd);
G_free(out.rast);
- G_close_cell(out.fd);
- G_short_history(out.name, "raster", &history);
- G_command_history(&history);
- G_write_history(out.name, &history);
+ Rast_close(out.fd);
+ Rast_short_history(out.name, "raster", &history);
+ Rast_command_history(&history);
+ Rast_write_history(out.name, &history);
char command[300];
@@ -252,7 +216,7 @@
sprintf(command, "r.colors map=%s color=grey", out.name);
system(command);
}
- G_close_cell(dem.fd);
+ Rast_close(dem.fd);
}
exit(EXIT_SUCCESS);
Modified: grass-addons/grass7/imagery/i.topo.corr/test_i.topo.corr_synthetic_DEM_NC.sh
===================================================================
--- grass-addons/imagery/i.topo.corr/test_i.topo.corr_synthetic_DEM_NC.sh 2011-08-04 15:37:24 UTC (rev 47448)
+++ grass-addons/grass7/imagery/i.topo.corr/test_i.topo.corr_synthetic_DEM_NC.sh 2011-08-04 17:23:41 UTC (rev 47449)
@@ -45,9 +45,9 @@
solarzenith=`echo $sunangleabovehorizon | awk '{printf "%f", 90. - $1}'`
# shade relief
-r.shaded.relief map=myplane_pyr shadedmap=myplane_pyr_shaded altitude=$sunangleabovehorizon azimuth=$sunazimuth
-d.mon stop=x0
-d.mon x0
+r.shaded.relief input=myplane_pyr output=myplane_pyr_shaded altitude=$sunangleabovehorizon azimuth=$sunazimuth
+d.mon stop=wx0
+d.mon wx0
d.rast myplane_pyr_shaded
# pre-run: illumination map
@@ -60,29 +60,30 @@
#making the 'band' reflectance file
r.mapcalc "myplane_pyr_band = double((myplane_pyr_shaded - 60.)/18.)"
-d.mon stop=x0
-d.mon x0
-d.rast.leg myplane_pyr_band
+d.mon stop=wx0
+d.mon wx0
+d.rast myplane_pyr_band
+d.legend myplane_pyr_band
## test it:
# percent
METHOD=percent
i.topo.corr input=myplane_pyr_band output=myplane_pyr_topocorr_${METHOD} basemap=myplane_pyr_illumination zenith=$solarzenith method=$METHOD
-d.mon stop=x1
-d.mon x1
+d.mon stop=wx1
+d.mon wx1
d.rast.leg myplane_pyr_topocorr_${METHOD}.myplane_pyr_band
# minnaert
METHOD=minnaert
i.topo.corr input=myplane_pyr_band output=myplane_pyr_topocorr_${METHOD} basemap=myplane_pyr_illumination zenith=$solarzenith method=$METHOD
-d.mon stop=x2
-d.mon x2
+d.mon stop=wx2
+d.mon wx2
d.rast.leg myplane_pyr_topocorr_${METHOD}.myplane_pyr_band
# c-factor
METHOD=c-factor
i.topo.corr input=myplane_pyr_band output=myplane_pyr_topocorr_${METHOD} basemap=myplane_pyr_illumination zenith=$solarzenith method=$METHOD
-d.mon stop=x3
-d.mon x3
+d.mon stop=wx3
+d.mon wx3
d.rast.leg myplane_pyr_topocorr_${METHOD}.myplane_pyr_band
More information about the grass-commit
mailing list