Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I've got one field X with 10 numerical attributes (float/double).

I've created a new field Y (also float/double) which I need to populate with the percentage of each record/attribute (in each of the 10 rows) relative to the MAX value in field X, i.e. something like Y=X/max(!X!).

I need to do this using the field calculator - in VB script or Python.

Any suggestions? I thought using max before the field name would suffice? (I assumed it was a built-in-function from Python in ArcGIS).

share|improve this question

migrated from stackoverflow.com Mar 24 at 16:23

This question came from our site for professional and enthusiast programmers.

    
Please show your code and explain what isn't working as you expected. Do you get an error? If so, what is it? –  Ansgar Wiechers Feb 7 at 9:40
    
If I use the code above with Python script Y=!X!/max(!X!) it gives me 1 as the result for all the fields as it replaces !X! with the numerical value for each respective row (basically dividing with itself rather than using the max value in field X as the denominator. –  GeosDK Feb 7 at 13:19
    
If I use VB Script it throws an error saying "There was a failure during processing, check the Geoprocessing Results window for details" (i.e. Error 999999 Error exectuing function). I've tried adding commas - different sorts -, checking spaces etc. Nothing works. –  GeosDK Feb 7 at 13:24
    
Eventually I resorted to looking for the max value by ascending the values in field X and using that value to the denominator in the field calculator. However, I would still like to find out whether it would be possible for the field calculator to populate a field automatically by searching the cursor for the max value (I know this is possible when looking for max values in multiple fields, but can't find the same for a single field) –  GeosDK Feb 7 at 13:25

1 Answer 1

If there is no other more direct way you could create an empty list and populate it with x field, maximum in a list is then easily found and used to populate the y fields.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.