Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In QGIS field-calculator round() is not working in QGIS 1.8 so I try to do the following with a regex: I'd like to keep the first two places after the decimal point - where do I go wrong?

regexp_replace( tostring( "Shape_Area" / 10000 ), '(\d+\.\d{2})\d+', '\1')

enter image description here

share|improve this question
Hi Kay, could you give a little more context about where you run this code and what the result you get, along with previous research and things you have already tried. – Matthias Kuhn May 29 '13 at 11:14
Matthias, I edited the original post. – Kay May 29 '13 at 12:49
There would be simpler ways to achieve these results using e.g. rounding functions. Or are you trying to learn regex? – underdark May 29 '13 at 13:42
Doesn't the FC have an 'int', 'floor', or 'ceiling' function? (Rounding is usually implemented via truncation, like int, under the hood anyway, as in int("Shape_Area" * 100 + 1/2)/100.) – whuber May 29 '13 at 16:36
@underdark, 1.8 doesn't support round() as I understood it.. – Kay May 29 '13 at 20:16
up vote 4 down vote accepted

This one works for me

toint(value * 100) / 100.0
share|improve this answer
it is as simple as that - thanks! (i'm still keen to know what the error in the regex caused..) – Kay Jun 1 '13 at 17:31

You might try '(\d+\.\d\d)\d+', '\1')

share|improve this answer
tried this before - still get the same error.. – Kay Jun 1 '13 at 17:32

Your Answer


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.