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

Radim Blazek radim.blazek at gmail.com
Thu Aug 25 06:16:30 EDT 2005


Hi,

I think that the possibility to "drape" a vector is of general use 
(vector line profile for example) and it should be in a separate 
module. 
Could you try to write a new v.drape which takes 2D vector and 
DEM as input and writes out 3D vector? You have written already 
the most important part below. Take an existing module (e.g. v.split)
and add your code for raster values. Dont forget to open the new 
vector as 3D ( Vect_open_new(,,1) ); 

I am ready to help you (as I see that you don't need any help).

Radim


On 8/25/05, Dylan Beaudette <dylan at iici.no-ip.org> wrote:
> Hi,
> 
> 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
> hard:
> 
> /* 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
> 530.754.7341
> 
>




More information about the grass-user mailing list