[GRASS-dev] v.perturb

Moritz Lennert mlennert at club.worldonline.be
Thu Aug 28 06:09:44 PDT 2014

On 28/08/14 14:55, Alessandro Samuel Rosa wrote:
> My objective is to perform a spatial simulated annealing schedule. It
> works as follows:
> 1) generate a set of n points randomly positioned in the study area
> (v.random);
> 2) query values from raster maps (r.what);
> 3) calculate an statistic;
> 4) randomly perturb one randomly selected point;
>     - the point has to fall withing the study area;
> 5) go through 2-4 till the statistic meets a given criterion.
> Ideally, v.perturb would do step 4: allow for perturbing a single point
> and check if it still falls inside the study area. If the point falls
> outside the study area, then it should be forced to the closest position
> within the study area.

Until someone adds this functionality to v.perturb, you could just use a 
loop like this:

- v.extract your point (possibly v.extract -r the other points)
- perturb extracted point
- while point outside region (you can check either mathematically using 
the points coordinates that you can get via v.to.db or you can use 
v.select the point with the region polygon and check whether the result 
is empty or no)
	- perturb the point again


More information about the grass-dev mailing list