vendredi 7 août 2015

I have a shapefile having 2 fields (code and fd_10f ) according to the code , go the dictionary of the code and return it according to fd as key

RONBB = {'0': 0.0, '1': 2.5, '2': 13.4, '3': 23.3, '4': 32.1, '5': 40.1, '6': 47.1, '7': 53.2, '8': 58.6, '9': 63.2, '10': 67.2, '11': 70.5, '12': 73.2, '13': 75.4, '14': 77.2, '15': 78.5, '16': 79.5} expression_s="PDS( !str_code!, !FD_10f!)" codeblock_s="def PDS(code,md):\n fd = math.trunc(md*3.28084)\n if code == \"RONB\":\n return RONBB['1']\n else:\n return 9999"
arcpy.AddField_management(watershed, "pDS_10", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "") arcpy.CalculateField_management(Output_Feature_Class, "pDS_10", expression_s, "PYTHON", codeblock_s)




Aucun commentaire:

Enregistrer un commentaire