Using ArcGIS 10.4

I have a line (shapefile) with lots of information. In 8 columns there are groups of species (Group 1 to Group8), indicating if this is the dominant species group in the area or not. Then for every row there is one group that has a 1 (dominant) and all the other 7 have a 0. In rare cases non of the species groups is dominant (all are 0).

Now, I need ONE raster file with this information. My idea was a raster with the numbers 1 to 8 indicating the dominant species group. But I cant get it to work. First I used feature to raster to extract each of the 8 columns. Then I tried to merge them into one raster with the mosaic to new raster tool. But of course this only gives me a file with 0 and 1 again.

How could I get this done?

  • Please provide a picture of a few rows and the row headings in your table to make what you are trying to describe in words clearer.
    – PolyGeo
    Apr 6, 2018 at 10:26

1 Answer 1


This is one way to do it. Script will add a new field called DomGroup and add dominant group id. If all groups are 0 id will be 0. Then run feature to raster with new field as input:

import arcpy

feature_class = r'C:\folder\shapefile' #Change this to match your shapefile
field_names = ['Group1', 'Group2','Group3','Group4','Group5','Group6','Group7','Group8'] #And this if your fields are named differently
new_field_name = 'DomGroup'
arcpy.AddField_management(in_table=feature_class, field_name=new_field_name, field_type='LONG')

with arcpy.da.UpdateCursor(feature_class,field_names) as cursor:
    for row in cursor:
        if max(row[:-1]) == 0: #Check if there is no dominant species (max value 0)
            row[-1] = 0
            row[-1] = row[:-1].index(max(row[:-1]))+1 #Find index of max value

enter image description here

  • 1
    BERA, your answer helped me in a minute. I double checked, everything is exactly how I need it. Thank you so much!!! I thought there would be an easy way to combine tools. But I guess Python is the only really handy solution for problems like this. Thank you!!!
    – Canna
    Apr 6, 2018 at 11:03
  • Nice! I dont think there is a tool for this.
    – BERA
    Apr 6, 2018 at 11:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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