I am trying to conduct a multicriteria evaluation, and it is necessary to check the compatibility of two different land-use types that I have in seperate layers. I am working in gvSIG 1.12, and have a unioned layer which contains polygons which are made up of land use A and B, included in the table is compatibility of Land-use A with each instance of B, but I need to create a final column that can select the correct number. An example of my attribute table is shown below.
Compatibility:
ID | Land-use A | Agr | Urb | For | Com | Pub | Land-use B | Compat
1 N 1 4 3 0 2 Agr
2 G 2 3 5 1 0 Pub
3 K 4 2 3 5 1 Urb
4 N 1 4 3 0 2 Urb
I am particularly struggling with getting the syntax correct for the Expression calculator. Should this be feasable using the preset commands in gvSIGs expression calculator or do I need to import the expression from a file (for instance a .py). In excel this is a simple if statement does the job but I am unable to execute this in gvSIG.
An example of my desired attribute table can be seen below:
Desired:
ID | Land-use A | Agr | Urb | For | Com | Pub | Land-use B | Compat
1 N 1 4 3 0 2 Agr 1
2 G 2 3 5 1 0 Pub 0
3 K 4 2 3 5 1 Urb 2
4 N 1 4 3 0 2 Urb 4
def COMPAT(Agr,Urb,For,Com,Pub,LanduseB): if LanduseB=="Agr": result=Agr elif LanduseB=="Urb": result=Urb elif LanduseB=="For": result=For elif LanduseB=="Com": result=Com elif LanduseB=="Pub": result=Pub else: result=-1 return result
This is loaded via the advanced tab in the expression calculator, and then in the general tab the following is entered:COMPAT([Agr],[Urb],[For],[Com],[Pub],[LanduseB])