hello,<br><br>something strange, i was quite sure to have send a response but it seems something goes wrong ...<br><br>I wrote a little script that use r.mode:<br>- convert the vector with polygon to raster<br>- loop for each polygon<br>
- get the mode and update the specified column in the vector file <br><br>it process only one polygon at a time and is quite slow, but do the job ;)<br><br>cheers,<br>Sylvain<br><br>[code]<br>#!/bin/bash<br><br># vector with polygon<br>
vect=Parcellaire<br># name of the column to store the mode <br>col=new2000<br># name of your data_map raster<br>cover=classif<br># name for the tmp raster to compute the polygon<br>base=parcelles<br><br>g.region rast=${cover}<br>
v.to.rast input=${vect} output=${base} use=cat<br><br>for cat in `r.stats ${base} | grep -v "*"`<br>do<br><br>cat_u=$(($cat - 1))<br>cat_o=$(($cat + 1))<br><br>g.copy rast=${base},${base}.${cat}<br>r.null map=${base}.${cat} setnull=0-${cat_u},${cat_o}-11000<br>
g.copy rast=${base}.${cat},MASK<br>r.mapcalc "${cover}.${cat}=${cover}"<br>r.mode base=${base}.${cat} cover=${cover}.${cat} output=${base}.${cat}.reclass --o --v<br>class=$(echo `r.stats ${base}.${cat}.reclass | grep -v "*"`);<br>
v.db.update map=${vect} column=${col} value=${class} where="cat=${cat}"<br>g.remove rast=MASK,${base}.${cat}.reclass,${base}.${cat},${cover}.${cat}<br><br>done<br>[/code]<br><br>