[GRASSLIST:8052] adding raster sampling to v.out.pov

Dylan Beaudette dylan at iici.no-ip.org
Wed Aug 24 18:01:09 EDT 2005


looking at the source code to v.out.pov, the creation of POVRAY objects 
appears to be rather simple. An example output from v.out.pov might look 
something like this:

#a simple line file:
v.out.pov in=trails type=line out=trails.pov   
#will produce an output like this:
sphere_sweep { linear_spline 668,
 <661310.722783, 0.000000 , 4038858.870877>, 10
in the format:  <x,z,y>,size

currently v.out.pov has the ability to set a fixed z-value, however it would 
be fantastic if it could read a raster (a DEM) at each one of these points, 
so that the z-value can be set automatically for each point.

Looking into v.what.rast, sampling a raster at a given point doesn't seem too 

/* Extract raster values from file and store in cache */
    cur_row = -1;
    for (point = 0 ; point < point_cnt ; point++) {
	if ( cache[point].count > 1 ) continue; /* duplicate cats */
        if (cur_row != cache[point].row) {
	    if ( out_type == CELL_TYPE ) {
		if ( G_get_c_raster_row ( fd, cell, cache[point].row) < 0 )
		    G_fatal_error ( "Can't read raster" );
	    } else {
		if (G_get_d_raster_row (fd, dcell, cache[point].row) < 0)
		    G_fatal_error ( "Can't read raster" );
	cur_row = cache[point].row;
	if ( out_type == CELL_TYPE ) {
	    cache[point].value = cell[ cache[point].col ];
	} else {
	    cache[point].dvalue = dcell[ cache[point].col ];
    } /* point loop */

Since I am not the best of programmers (hacking together something is one 
thing but...) I was wondering if Radim or others who do work on the vector 
modules could give me some pointers on adding this functionality to v.out.pov 
- or if other GRASS users are interested, adding this to v.out.pov. 

This seems like a useful thing to do, as it would allow vector features 
exported to POVRAY to be "draped" over an elevation surface, much in the same 
way that NVIZ can do.

Any thoughts?

Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis

More information about the grass-user mailing list