[GRASS5] r.random broken

Hamish hamish_nospam at yahoo.com
Sat Jun 4 11:52:13 EDT 2005


> > >> I just tried to use r.random to generate a set of random points
> > >> across the Spearfish dem file_to illustrate interpolation.
> > >> 
> > >> When I display the points, they are all clustered along the top
> > >> (i.e., north) edge. This happens with both raster and vector
> > >> points, and when I run it against both elevation.dem and
> > >> elevation.10m. It looks something is wrong with the algorithm to
> > >> generate the y values.
> > > 
> > > r.random totally won't work if either __CYGWIN__ or __APPLE__ are
> > > defined, due to the following in raster/r.random/creat_rand.c:
> > > 
> > > #if defined(__CYGWIN__) || defined(__APPLE__)
> > > #define lrand48() rand()/32767.0
> > > #define srand48(sv) (srand((unsigned)(sv)))
> > > #else
> > > 
> > > lrand48() is supposed to return random numbers between 0 and 2^31.
> > > The above lrand48() macro will end up returning values which are far
> > > too small, so, the random test will return true too often, resulting
> > > in the desired number of random cells being reached far too early.
> ..
> 
> just replace 32767.0 with 2^31. Maybe try-


sorry, ignore that.

better:

#define lrand48() rand()*65536.



Hamish





More information about the grass-dev mailing list