No subject

charnotw charnotw at helios.aston.ac.uk
Thu Sep 7 05:15:58 EDT 1995


> I am writing a converter to convert from DEM to GRASS raster format.
> 
> I use G_open_new_cell_random() to create the new raster file. According to
> progman.ps, when I call G_close_cell(), it will write the header file. How
> do I set the header info for the cell data so that it will be saved?
> 
> Should I modify G__.fileinfo[fd]->cellhd to set it?            
> Or should I call G_put_cellhd() after calling G_close_cell?
> 
> Modifying the G__ structure seems more logical and efficient, but it is 
> used in gislib only, so perhaps it shouldn't be accessed directly.
> 
> The documentation (progman.ps) says that programmers shouldn't need to
> use G_put_cellhd. Also, the write routine for cell files 
> G_put_map_row_random() uses G__.fileinfo[fd]->cellhd to determine what
> to write (to see if it's inside the region or not).
> 
> Eric
> eric at detritus.ees.wesleyan.edu 

Header information is automatically created for a new raster from the active
region.  When you start a program run the active region of the program
is the same as the current region in the file WIND, you can change
the active region using the G_set_region function.  It is important
not to change the active region when there are rasters already open.

eg

struct Cell_head new_region;
int fd;

new_region.north=40000;
new_region.south=20000;
new_region.east=20000;
new_region.west=10000;
new_region.ns_res=50;
new_region.ew_res=50;

G_set_region(&new_region);

fd=G_open_cell_new_random("name");

/*do stuff*/

G_close_cell(fd);

the active regino will be forgotten when the prgram ends, and GRASS reverts to
the current region. You shouldn't need to modify the header information directly.


cheers  Tom


Tom Charnock                       O--O
Dept Civil Engineering            (~~~~)
Aston University                 (  __  )
Birmingham B4 7ET UK             /|\  /|\
charnotw at sun.aston.ac.uk



More information about the grass-user mailing list