AnsweredAssumed Answered

Populating geodatabase field based on query using two other fields

Question asked by map.girl on Mar 15, 2013
Latest reply on Mar 28, 2013 by map.girl
I am struggling with how to approach filling in the field ???Code??? using python from within an ArcMap 10.1 Advanced license session. I tried to use the calculate field tool in model builder but could not get the code right in the Code Block. I also tried to use the UpdateCursor but still could not get the syntax right. Below is a description of what snippet of code I am struggling with now and my ultimate output goal. Any and all help on any part of this output would be greatly appreciated. Sample of geodatabase table attached.

if PERCENTAGE => 100 AND PCNT_BUFF => 100 then Code = 1
elif PERCENTAGE => 100 AND 0 < PCNT_BUFF < 100 then Code = 2
elif 0 < PERCENTAGE < 100  AND < PCNT_BUFF < 100  then Code = 3
elif PERCENTAGE <=0 AND 0 < PCNT_BUFF < 100 then Code = 4
else PERCENTAGE <= 0 AND PCNT_BUFF <= 0 then Code = 5

What I am trying to do is to populate the Code field in the TI_Test geodatabase table using the above parameters.
Ultimately I will be sorting and counting the values for Code. Each value will have a specific sentence that results will be plugged into. The table values will change each time I run the script on a project area.
For instance:

Value 1 = Distribution of  <CommonName> completely cover(s) the project area and buffer area.
Value 2 = Distribution of  <CommonName> completely cover(s) the project area and some of buffer area.
Value 3 = Distribution of  <CommonName> cover(s) some the project area and buffer area
Value 4 = Distribution of  <CommonName> cover(s) some of the buffer area only
Value 5 = No distribution of <CommonName> cover(s) the project or buffer area.

Count will be needed because the number of species (CommonName) will determine whether commas and the word ???and??? will be required.

Thus if the Code and CommonName for records 1-4 (there will always be just 4 records) was:

1, Mule Deer; 1, Pronghorn antelope; 5, Bighorn sheep; 3, Elk

The resulting text file would look like this (output of sentences sorted by code value):

Distribution of Mule deer and Pronghorn antelope completely cover the project area and buffer area. Distribution of Elk covers some the project area and buffer area. No distribution of Bighorn sheep covers the project or buffer area.

If the table looks like this:

4, Mule Deer; 2, Pronghorn antelope; 2, Bighorn sheep; 2, Elk

The resulting text file would look like this (note cover(s) is variable too):

Distribution of Pronghorn antelope, Bighorn sheep, and Elk completely cover the project area and some of buffer area. Distribution of Mule deer covers some of the buffer area only.

Attachments

Outcomes