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.

this might be a pure python problem or a problem with arcpy. please help me out:

    min_area = float(GKPROZ_functions.min_of_field(out_name,"Shape_Area"))
    print area_max
    if min_area > area_max:
        print "success!"
    else:
        print "failed."            

    if min_area > 100:
        print "success!"
    else:
        print "failed."

    print str(min_area)

output:

100
failed.
success!
100.018289077

min_of_field returns the minimum value of the field "Shape_Area" of the whole feature class. it is (apparently) 100.018289077. however if i check that with area_max (supposedly 100) it says it's smaller (failed!). if i check it with 100, it says it's bigger(success!). what mistake am i making here? thanks in advance.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

The code you have provided does not show how area_max is assigned a value. When I ran your code, assigning area_min = float(100.0182890771) and area_max = float(100) I get a correct output:

success!
success!
100.018289077

However, If I assign area_max = str(100) I am able to replicate the error:

failed.
success!
100.018289077

It could be that your error is in the assignment of the area_min value but its hard to say for sure without that part of the code.

share|improve this answer
    
this was indeed the problem. i am still unexperienced with python and the ambiguity of types tricked me into thinking everything was ok. thank you for your time! –  Ben the bear Aug 31 '12 at 11:01
    
You're welcome. It can be tricky to begin with, but you'll soon learn to check for these things. –  sgrieve Aug 31 '12 at 11:12
add comment

Your Answer

 
discard

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

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