r.in.sunrast
Bob Courtney
courtney at agcrr.bio.ns.ca
Wed Sep 16 09:21:42 EDT 1992
There is a bug in r.in.sunrast. The sun raster format assumes an even
number of pixels for each row in storage. If the input image has an odd
number of pixels in a row, then an extra blank byte is added to each
row in the file.
The result is that images with an even number of pixels import properly
using r.in.sunrast, but images with an odd # in each row are offset
by 1 byte to the preceeding row.
FIX :
( caveat, I am not a C programmer!)
cd src.alpha/raster/r.in.sunrast/cmd
and edit main.c
replace the function rasttocell with :
rasttocell (rast_fd, cell_fd, nrows, ncols)
{
unsigned char *raster;
CELL *cell;
int row, col, ncol_fix ;
/* check if row is even or odd */
ncol_fix = ncols;
if ( ncols % 2 )
ncol_fix += 1 ;
cell = G_allocate_cell_buf();
raster = (unsigned char *) G_malloc(ncols);
if (verbose)
fprintf (stderr, "complete ... ");
for (row = 0; row < nrows; row++)
{
if (verbose)
G_percent (row, nrows, 2);
if (read (rast_fd, raster, ncol_fix) != ncol_fix)
return -1;
for (col = 0; col < ncols; col++)
cell[col] = (CELL) raster[col];
if (G_put_map_row (cell_fd, cell) < 0)
exit(1);
}
if (verbose)
G_percent (row, nrows, 2);
return 1;
}
and recompile
Good Luck
Bob Courtney
Atlantic Geoscience Centre
More information about the grass-user
mailing list