-1

I am receiving the following error; is it a simple syntax issue with the Calculate field because I'm not seeing anything missing.

ExecuteError: ERROR 000539: SyntaxError: unexpected EOF while parsing (<expression>, line 1)
Failed to execute (CalculateField).
def calculate_pop(boundary, area_numbe, community):
   arcpy.Clip_analysis(bgs_places,boundary, r'in_memory\BG_Clip_temp')
   arcpy.MakeFeatureLayer_management(r'in_memory\BG_Clip_temp','Pop_Layer')    
   arcpy.AddField_management('Pop_Layer','BGAREA','DOUBLE')
   arcpy.CalculateField_management('Pop_Layer','BGAREA','!shape.area!','PYTHON')
   arcpy.AddField_management('Pop_Layer','TOTPOP_17','LONG')
   #How to calculate Total Population
   arcpy.CalculateField_management('Pop_Layer','TOTPOP_17','((!TOTPOP_CY!*(!BGAREA!/!AREA!))','PYTHON')
   stats_temp=r'in_memory\Place_'+boundary+'_Temp_Pop_Statistics'
   arcpy.AddField_management('Pop_Layer','TOTPOP_17','LONG')
   arcpy.Statistics_analysis('Pop_Layer', stats_temp,"BGAREA;TOTPOP_17", "")

totpop_table=calculate_pop('Bndry_Lyr', area_numbe, community)
append_stats(totpop_table)
  • 1
    Fix the formatting so we can see what you are doing. How are you calling the function? – BERA Jan 26 '18 at 7:16
  • @Hornbydd what line? its erroring on the Calculate field and there isn't one missing. – Purplepeopleeater Jan 26 '18 at 14:36
  • Apologies I misread the line! Comment removed. – Hornbydd Jan 26 '18 at 16:05
  • @Hornbydd I think you were correct, I had too many '()' – Purplepeopleeater Jan 26 '18 at 16:14
1
arcpy.CalculateField_management('Pop_Layer','TOTPOP_17','!TOTPOP_CY!*(!BGAREA!/!AREA!)','PYTHON')

This is the corrected line of code, where I removed parenthesis that was not needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.