[GRASSLIST:355] Re: a huge matrix ?
Sandro Klippel
sandro.klippel at talha-mar.com.br
Wed Jun 11 18:31:42 EDT 2003
Perhaps you can use the r.infer
The probability values can be inserted in the category labels, and
recovery by r.mapcalc (map = @infer).
I do not know if is functional with so much rules.
IFMAP map1 cat#
ANDIFMAP map2 cat#
ANDIFMAP map3 cat#
...
THENMAPHYP 1 probability2
!
IFMAP map1 cat#
ANDIFMAP map2 cat#
ANDIFMAP map3 cat#
...
THENMAPHYP 2 probability2
...
...
...
On Wed, 2003-06-11 at 12:45, Glynn Clements wrote:
>
> orkun wrote:
>
> > >>I have a huge matrix containing 7 column and 10500 rows.
> > >>Each columns stand for different maps. Each rows represent "unique"
> > >>combinations of catagories of maps and probability values
> > >>of each row.
> > >>Something like:
> > >>
> > >> map1 map2 map3 ... prob
> > >>1 cat1 x x x x
> > >>2 cat2 x x x x
> > >>. .
> > >>. .
> > >>10500 .
> > >>
> > >>So I have 10500 if-clause to create a probability map.
> > >>I tried r.mapcalc (as from a text file) but grass gave "stack overflow"
> > >>error.
> > >>
> > >>
> > >
> > >I'm not surprised.
> > >
> > >
> > >
> > >>Is there anyone making suggestions ?
> > >>
> > >>
> > >
> > >You need to describe your problem in more detail; it isn't clear what
> > >you are trying to calculate.
> > >
> > >
> > >
> > Thank you for your interest
> >
> > You wanted to know the problem in more detail:
> >
> > what I did:
> > 1- using r.stat command I produced a text file for statistical calculations
> > 2- using R statistical package I produced probability results of each
> > map's for each categories.
> > it means 7 columns of maps 10500 rows plus probability of each
> > combination. Actually it is a contingency table. Any data in table
> > (matrix) is resulting from unique combination of maps and their
> > categories.
> > 3- I want to port these results to grass to create a map (of landslide
> > susceptibility map) . Firstly I thought I used r.mapcalc with piping
> > from text file. But because text file contains a huge matrix that is
> > made up of 10500 if statement (for same number of rows) process failed.
> > I attached a part of text file after modifying for r.mapcalc. you see
> > all ifs are unique.
>
> OK, so: each line is a rule; for each pixel you scan the list of rules
> to find the first match, then output the associated result. Right?
>
> The most straightforward approach (although not particularly
> efficient), would be to use an iterative approach, i.e.
>
> n=0
> last='null()'
> while read a1 a2 a3 a4 a5 a6 a7 a8 ; do
> result=pr2.pass$n
> r.mapcalc "$result = if (f28geo5==$a1 && f28slpcat==$a2 && f28concavity==$a3 && n_facing==$a4 && road_bas==$a5 &&str_buf==$a6 && f28f4==$a7, $a8, $last)"
> last=$result
> done < rules.txt
>
> where rules.txt looks like:
>
> 21 6 1 1 1 1 0 701.22
> 7 4 2 1 1 2 1 702.06
> ...
>
> Alternatively, you could combine this with your initial approach, only
> matching a limited number of rules on each pass, and using several
> passes.
>
> However, I note that there seem to be very few possible values for
> most of the maps. In that case, a far more efficient approach would be
> to:
>
> 1. Reclass each input map so that all of the significant categories
> are consecutively numbered from zero (0,1,2,3,...); any insignificant
> categories would be merged into the last category.
>
> 2. Compute a composite map, using e.g.
>
> composite = f28geo5 + 22 * (f28slpcat + 9 * (f28concavity + 3 * ...
>
> where the numbers are the total number of categories in the preceding
> map.
>
> 3. Assign the values as labels for the composite categories.
>
> 4. Use "@map" in r.mapcalc to use the label instead of the category.
>
> --
> Glynn Clements <glynn.clements at virgin.net>
--
Sandro Klippel <sandro.klippel at talha-mar.com.br>
talha-mar projetos ambientais
Conselheiro d'Avila 190
Porto Alegre,RS 91040-450
+55 (51) 3344-7451
w w w . t a l h a - m a r . c o m . b r
More information about the grass-user
mailing list