[GRASS-user] Comparing 2 large Corine Land Cover maps

Paulo van Breugel p.vanbreugel at gmail.com
Sat Jul 23 18:15:29 EDT 2011


Maybe r.cross can be of help. It creates a cross product of the category
variables of a layer, i.e., a map with separate categories for each unique
combination of the two CLC maps (the category labels gives you the
combination of input maps for each new category).

You can use this new map to create a reclass map with the new values from
your decision matrix. To do this, you could for example follow the following
steps:

1) Run r.category to get a list with the categories and category labels of
the cross product map you just created. You can output this as a text file
2) Use a spreadsheet or something like awk to create a textfile with three
columns, one with the new category, and two with the clc2000 and clc2006
categories
3) Find a way to link the CLC combinations in your text file to the new
classes given in your decision matrix (use e.g., spreadsheet or database)
4) Use this new table to create the reclassification rules you need in the
next step (again, if you know awk this will probably be very easy, but also
in R or in a spreadsheet this is easy to do).
5) Create a text file with reclassification rules (see r.reclass how these
should look like) and use r.reclass to reclassify the map you just created
with r.cross.

I guess there must be easier ways. But in any case, these steps are not very
difficult to implement. And in case you have to repeat this type of analysis
more often, once you have set up a workflow, it will be easy to repeat
(especially if you manage to implement all steps as a script).



On Fri, Jul 22, 2011 at 12:41 PM, Hermann Peifer <peifer at gmx.eu> wrote:

> Hi,
>
> I have 2 Corine Land Cover (CLC) raster maps, from 2000 and 2006. Both maps
> have the same extent, the same resolution (100m) and use the same 44 CLC
> categories. The maps are pretty large: 67 000 cols x 58 000 rows = 3 886 000
> 000 cells.
>
> I'd like to categorise the changes between the 2 layers, according to a
> decision matrix which I pasted below [1]. Row headers indicate the clc2000
> category, column headers represent the clc2006 category. I only pasted the
> "left half" of the table in order to avoid ugly line breaks.
>
>
> Question:
> Is there a better (and faster) way than doing this comparison by using
> r.mapcalc with a (nearly) endless if/else chain [2] ?
>
> I also noted that in 99+ % of the cases, both maps are NULL or have an
> identical CLC category, so I wouldn't need the if/else chain at all. I guess
> I can use this fact to shortcut the comparison?
>
>
> Thanks in advance, Hermann
> (using GRASS 6.4 on 64-bit Debian Linux)
>
> [1]
>
> ##  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 ..
>  1 NA 12 31 32 33 34 35 36 37 13 38 56 56 56 56 56 56 56 56 56 56 56 ..
>  2 11 NA 31 32 33 34 35 36 37 13 38 56 56 56 56 56 56 56 56 56 56 56 ..
>  3 12 12 NA 32 33 34 35 36 37 13 38 56 56 56 56 56 56 56 56 56 56 56 ..
>  4 12 12 31 NA 33 34 35 36 37 13 38 56 56 56 56 56 56 56 56 56 56 56 ..
>  5 12 12 31 32 NA 34 35 36 37 13 38 56 56 56 56 56 56 56 56 56 56 56 ..
>  6 12 12 31 32 33 NA 35 36 37 13 38 56 56 56 56 56 56 56 56 56 56 56 ..
>  7 12 12 31 32 33 34 NA 36 37 13 38 56 56 56 56 56 56 56 56 56 56 56 ..
>  8 12 12 31 32 33 34 35 NA 37 13 38 56 56 56 56 56 56 56 56 56 56 56 ..
>  9 12 12 31 32 33 34 35 36 NA 13 38 56 56 56 56 56 56 56 56 56 56 56 ..
> 10 11 11 31 32 33 34 35 36 37 NA 38 56 56 56 56 56 56 56 56 56 56 56 ..
> 11 11 11 31 32 33 34 35 36 37 13 NA 56 56 56 56 56 56 56 56 56 56 56 ..
> 12 21 22 31 32 33 34 35 36 37 13 38 NA 45 43 42 42 42 41 42 41 83 61 ..
> 13 21 22 31 32 33 34 35 36 37 13 38 43 NA 43 42 42 42 41 42 41 83 61 ..
> 14 21 22 31 32 33 34 35 36 37 13 38 43 43 NA 42 42 42 41 42 41 83 61 ..
> 15 21 22 31 32 33 34 35 36 37 13 38 45 45 45 NA 44 44 41 45 45 83 61 ..
> 16 21 22 31 32 33 34 35 36 37 13 38 45 45 45 44 NA 44 41 45 45 83 61 ..
> 17 21 22 31 32 33 34 35 36 37 13 38 45 45 45 44 44 NA 41 45 45 83 61 ..
> 18 21 22 31 32 33 34 35 36 37 13 38 45 45 45 42 42 42 NA 45 45 83 61 ..
> 19 21 22 31 32 33 34 35 36 37 13 38 45 45 45 42 42 42 41 NA 41 83 61 ..
> 20 21 22 31 32 33 34 35 36 37 13 38 45 45 45 42 42 42 41 45 NA 83 61 ..
> 21 21 22 31 32 33 34 35 36 37 13 38 52 52 52 52 52 52 41 52 54 NA 54 ..
> 22 21 22 31 32 33 34 35 36 37 13 38 45 45 45 42 42 42 41 45 45 83 NA ..
> 23 21 22 31 32 33 34 35 36 37 13 38 51 51 51 51 51 51 53 51 53 53 53 ..
> 24 21 22 31 32 33 34 35 36 37 13 38 51 51 51 51 51 51 53 51 53 53 53 ..
> 25 21 22 31 32 33 34 35 36 37 13 38 51 51 51 51 51 51 53 51 53 53 53 ..
> 26 21 22 31 32 33 34 35 36 37 13 38 52 52 52 52 52 52 54 52 54 54 54 ..
> 27 21 22 31 32 33 34 35 36 37 13 38 52 52 52 52 52 52 54 52 54 54 54 ..
> 28 21 22 31 32 33 34 35 36 37 13 38 52 52 52 52 52 52 54 52 54 54 54 ..
> 29 21 22 31 32 33 34 35 36 37 13 38 52 52 52 52 52 52 54 52 54 54 54 ..
> 30 21 22 31 32 33 34 35 36 37 13 38 52 52 52 52 52 52 54 52 54 54 53 ..
> 31 21 22 31 32 33 34 35 36 37 13 38 52 52 52 52 52 52 54 52 54 54 53 ..
> 32 21 22 31 32 33 34 35 36 37 13 38 52 52 52 52 52 52 54 52 54 54 53 ..
> 33 21 22 31 32 33 34 35 36 37 13 38 52 52 52 52 52 52 54 52 54 54 53 ..
> 34 NA NA NA NA NA NA NA NA NA NA 38 NA NA NA NA NA NA NA NA NA NA NA ..
> 35 21 22 31 32 33 34 35 36 37 13 38 55 55 55 55 55 55 55 55 55 55 55 ..
> 36 21 22 31 32 33 34 35 36 37 13 38 55 55 55 55 55 55 55 55 55 55 55 ..
> 37 21 22 31 32 33 34 35 36 37 13 38 55 55 55 55 55 55 55 55 55 55 55 ..
> 38 21 22 31 32 33 34 35 36 37 13 38 55 55 55 55 55 55 55 55 55 55 55 ..
> 39 21 22 31 32 33 34 35 36 37 13 38 55 55 55 55 55 55 55 55 55 55 55 ..
> 40 21 22 31 32 33 34 35 36 37 13 38 55 55 55 55 55 55 55 55 55 55 55 ..
> 41 21 22 31 32 33 34 35 36 37 13 38 55 55 55 55 55 55 55 55 55 55 55 ..
> 42 21 22 31 32 33 34 35 36 37 13 38 55 55 55 55 55 55 55 55 55 55 55 ..
> 43 21 22 31 32 33 34 35 36 37 13 38 55 55 55 55 55 55 55 55 55 55 55 ..
> 44 21 22 31 32 33 34 35 36 37 13 38 55 55 55 55 55 55 55 55 55 55 55 ..
>
>
> [2]
>
> change = \
> clc2000 == 1 && clc2006 == 2 ? 12 : \
> clc2000 == 1 && clc2006 == 3 ? 31 : \
> clc2000 == 1 && clc2006 == 4 ? 32 : \
> clc2000 == 1 && clc2006 == 5 ? 33 : \
> clc2000 == 1 && clc2006 == 6 ? 34 : \
> clc2000 == 1 && clc2006 == 7 ? 35 : \
> clc2000 == 1 && clc2006 == 8 ? 36 : \
> clc2000 == 1 && clc2006 == 9 ? 37 : \
> clc2000 == 1 && clc2006 == 10 ? 13 : \
>
> ... (snip away some 1700 if/else rules)
>
> clc2000 == 44 && clc2006 == 30 ? 89 : \
> clc2000 == 44 && clc2006 == 31 ? 89 : \
> clc2000 == 44 && clc2006 == 32 ? 89 : \
> clc2000 == 44 && clc2006 == 35 ? 82 : \
> clc2000 == 44 && clc2006 == 36 ? 82 : \
> clc2000 == 44 && clc2006 == 37 ? 82 : \
> clc2000 == 44 && clc2006 == 38 ? 89 : \
> clc2000 == 44 && clc2006 == 39 ? 89 : \
> clc2000 == 44 && clc2006 == 42 ? 82 : \
> clc2000 == 44 && clc2006 == 43 ? 82 : 0
> ______________________________**_________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/**mailman/listinfo/grass-user<http://lists.osgeo.org/mailman/listinfo/grass-user>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20110724/4b075b8a/attachment-0001.html


More information about the grass-user mailing list