[GRASS-user] problems with r.neighborhoodmatrix

Moritz Lennert mlennert at club.worldonline.be
Mon Feb 26 08:01:14 PST 2018


Dear Grazia,

Once again: Please refrain from sending private mails.

I am happy that you found a solution, although I don't really understand 
how: your "object" map has only one single object. 
r.object.autocorrelation compares objects with their neighbors, as 
identified with r.neighborhoodmatrix, to calculate spatial 
autocorrelation. As you only have one object, there are no neighbors. 
So, you won't have any neighborhood matrix, and so no object-based 
spatial autocorrelation.

Moritz


On 26/02/18 16:48, Gra wrote:
> Hi Moritz
> just to tell you that I got it!
> I worked during the week end and I made it work (my error was on the 
> first input)
> 
> Thanks a lot for your help
> 
> Grazia
> 
> 2018-02-23 16:19 GMT+01:00 Gra <graziaz at gmail.com 
> <mailto:graziaz at gmail.com>>:
> 
>     Hi
> 
>     here is the result of r.info <http://r.info> of my map
> 
>     r.info <http://r.info> map=maskAT001L2_50 at in_data
>       +----------------------------------------------------------------------------+
>       | Map:      maskAT001L2_50 at in_data         Date: Tue Jan 23
>     16:46:56 2018    |
>       | Mapset:   in_data                        Login of Creator:
>     zuliagr         |
>       | Location: EnRoute_AT                                           
>                 |
>       | DataBase: /DATA/zuliagr/grassdata                               
>                |
>       | Title:    Categories                                           
>                 |
>       | Timestamp: none                                                 
>                |
>       |----------------------------------------------------------------------------|
>       |                                                                 
>                |
>       |   Type of Map:  raster               Number of Categories: 0   
>                 |
>       |   Data Type:    CELL                                           
>                 |
>       |   Rows:         2617                                           
>                 |
>       |   Columns:      2381                                           
>                 |
>       |   Total Cells:  6231077                                         
>                |
>       |        Projection: ETRS89 / LAEA Europe                         
>                |
>       |            N:    2879700    S:    2748850   Res:    50         
>                 |
>       |            E:    4854650    W:    4735600   Res:    50         
>                 |
>       |   Range of data:    min = 1  max = 1                           
>                 |
>       |                                                                 
>                |
>       |   Data Source:                                                 
>                 |
>       |    Vector Map: FUA_AT001L2                                     
>                 |
>       |    Original scale from vector map: 1:1                         
>                 |
>       |                                                                 
>                |
>       |   Data Description:                                             
>                |
>       |    generated by v.to.rast                                       
>                |
>       |                                                                 
>                |
>       |   Comments:                                                     
>                |
>       |    v.to.rast --overwrite input="FUA_AT001L2" layer="1"
>     type="point,line\   |
>       |    ,area" output="maskAT001L2_50" use="attr"
>     attribute_column="ras" val\   |
>       |    ue=1 memory=300
> 
>     practically this is the surface of a city (I am working 700 cities
>     in Europe)
>     I need to compute the moran stat for several indicators to see if
>     the are dispersed or clumped.
> 
>     I attach an example of inputs (result is the indicator).
> 
>     can I use your module?
>     if yes can you explain me how to organise the data?
> 
>     if you prefer I can move the conversation to the user list.
> 
>     Many thanks for your help
> 
>     Grazia
> 
>     PS I could not download the new version yet, I work under a proxy
>     and the downloading is a bit tricky, I will do that on Monday.
> 
> 
> 
> 
> 
>     2018-02-22 11:34 GMT+01:00 Moritz Lennert
>     <mlennert at club.worldonline.be <mailto:mlennert at club.worldonline.be>>:
> 
>         Hello Gra,
> 
> 
>         On 21/02/18 16:49, Gra wrote:
> 
>             I have this error with r.neighborhoodmatrix
>             could you help?
>             thanks
> 
> 
>             Traceback (most recent call last):
>                 File
>             "/home/zuliagr/.grass7/addons/scripts/r.neighborhoodmatrix",
>             line 190, in <module>
>                   main()
>                 File
>             "/home/zuliagr/.grass7/addons/scripts/r.neighborhoodmatrix",
>             line 150, in main
>                   for line in heapq.merge(*[decorated_file(f, keyfunc) for
>             f in files]):
>                 File "/usr/lib/python2.7/heapq.py", line 376, in merge
>                   h_append([next(), itnum, next])
>                 File
>             "/home/zuliagr/.grass7/addons/scripts/r.neighborhoodmatrix",
>             line 96, in decorated_file
>                   yield (key(line), line)
>                 File
>             "/home/zuliagr/.grass7/addons/scripts/r.neighborhoodmatrix",
>             line 92, in keyfunc
>                   return [int(x) for x in s.split(separator)[:2]]
>             ValueError: invalid literal for int() with base 10:
>             '0-0.003922'
> 
> 
>         The value 0-0.003922 seems to indicate that you are not using an
>         integer map. Calculating a neighborhood matrix only makes sense
>         for clearly defined objects and this implies an identification
>         with integer ids (such as the ones coming out of r.clump or
>         i.segment).
> 
>         To make sure this is the problem, please send us the r.info
>         <http://r.info> output on your input map.
> 
>         I just committed a revised version of the addon which checks the
>         map type and gives a fatal error if it is not the expected
>         integer type. Reinstall the extension and tell us what you get.
> 
>         BTW, you sent me a private mail [please don't do that: mails
>         should always go to the list] concerning an error in
>         r.object.spatialautocor where you also have an error in
>         r.neighborhoodmatrix, using the following command:
> 
>             r.object.spatialautocor ob=maskAT001L2_50
>             var=RPnAT001L2 at in_data method=moran
>             maskAT001L2_50 = raster map value 1
>             RPnAT001L2 = my variable
> 
> 
> 
>         I suspect the reason for the error is similar, but to make sure,
>         please send the output of
> 
>         r.info <http://r.info> maskAT001L2_50
> 
>         Moritz
> 
> 
> 




More information about the grass-user mailing list