AnsweredAssumed Answered

How to get user defined field values (multi-criteria, arcpy)?

Question asked by krasovecn on Oct 27, 2018
Latest reply on Nov 1, 2018 by rvburton

Hello!

I am currently involved in the project where we are creating a tool to assess flood risk using the multi-criteria analysis. We would like to give the user the option to decide on his/her own weights for each input. E.g. one of the inputs is geology (vector data) and we would like to make a script in a way that the user, after selecting the geology input, gets all of the geology classes from the attribute table and then chooses the weight for each geology class (the possible weights would be: 1,2,5,8 or 10).

This part of code is currently hardcoded and therefore the script is applicable only for our specific region:

arcpy.AddField_management('geologyDiss', 'weight', 'SHORT', 0)
try:
    with arcpy.da.UpdateCursor('geologyDiss',('geolS_eng','weight')) as cursor:
        for row in cursor:
            if row [0] == 'clay slate, marl, breccia, sandstone, conglomerate, chert':
                row[1] = 8
            elif row[0] == 'dolomite':
                row[1] = 2
            elif row[0] == 'flysch':
                row[1] = 10
            elif row[0] == 'igneous rock (diabase, spilite, porphyry, pyroclastics, keratophyre)':
                row[1] = 10
            elif row[0] == 'limestone, limestone with dolomite':
                row[1] = 1
            elif row[0] == 'moraine sediment':
                row[1] = 5
            elif row[0] == 'rivers and stream deposit, diluvium':
                row[1] = 5
            else:
               row[1] = 2
            cursor.updateRow(row)
        del row
        del cursor
except Exception as e:
    print e.message

Outcomes