Edit or calculate newly added field in a raster table based on cell values

1234
4
06-20-2017 04:24 AM
DataOfficer
Occasional Contributor III

Hi,


I have a raster dataset with cell values from 1 to 21, corresponding to different land cover types. I have added a new text field called 'Habitat' to the attribute table and would like to fill this based on call values, i.e. Value = 1 means Broadleaved woodland, Value = 2 means Coniferous woodland etc. I am using ArcGIS Pro 1.4. 

At first I simply tried to double-click the cells in the new field and type in the new text manually, as I would with a vector dataset. This didn't work and I am presuming this functionality isn't available for rasters. 

Next, I turned to the Calculate Field and, after looking at previous threads about this topic, attempted the following (I only used the first two values out of 21 to test the code):

def Habitat(Value)
if (Value = "1"):
   Habitat = "Broadleaved woodland"
elif (Value = "2")
   Habitat = "Coniferous woodland"

For the expression I used Habitat = (!Value!). 

Upon verifying this I got the following error message: 

 

Where did I go wrong? Is there an easier way of editing a field in a raster attribute table? Thanks!

0 Kudos
4 Replies
DanPatterson_Retired
MVP Emeritus

Since a raster doesn't have separate 'polygon's but rather zones, there should only be a single class for each 'zone', can't you just edit the table directly? (haven't done this in years, so I presume you have ruled out a table join as well)

0 Kudos
DataOfficer
Occasional Contributor III

Thanks Dan. I tried to edit the table directly but it won't let me many any changes to the cells. See below - I can highlight the cells but cannot enter any values/text. I might try ArcMap instead of Pro to see whether that makes a difference. 

0 Kudos
DanPatterson_Retired
MVP Emeritus

strangely, Calculate is available... I wonder if you can 'Calculate' the text in (which would seem weird... but a csv file in text form for joining would see appropriate

0 Kudos
DataOfficer
Occasional Contributor III

I've managed to do it now using the 'Join Field' tool. I thought I could perhaps do this more elegantly using Python script in 'Calculate Field' but as a complete novice to Python it seems needlessly complicated. Thanks for your help anyway!

0 Kudos