How do I use the ogr SetAttributeFilter with uppercases?

Code example:

lyr = shp_obj.GetLayer()
sel_str = "%s = '%s'" % (field, value)

Can I just do:

 sel_str = "UPPER(%s) = '%s'" % (field, value)


1 Answer 1


You don't need to according to the OGR SQL reference.

WHERE Limitations
All string comparisons are case insensitive except for <, >, <= and >=

  • I must have overseen this when I looked at the reference. Thanks mate.
    – LarsVegas
    Jul 26, 2013 at 8:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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