I created a grid of rectangular polygons with the Create Grid function, from the Vector Creation group of the Processing Toolbox in QGIS 3.4.2. The rectangles measure half a degree of longitude by half a degree of latitude.

When I want to label the polygons, I write an expression that rounds the values of latitude and longitude attributes to 2 decimal places, since the attributes created in the grid brings many decimal places.

But the round function rounds the values badly.

I know that I can create new attributes that express the coordinates with fewer decimal places and label the entities based on those attributes, but I was struck by the behavior of the function. I expected it to round to the nearest value.

Does anyone know what the problem is that the round function wrongly rounds off the decimal number?

Attached screenshots of Source Fields and the Attribute Table.



1 Answer 1


Actually I cannot replicate the same behavior that you have. I created a grid with 0.5 degree width of latitude and longitude, and I round it to 2 decimal degree and it works fine. Then I added another column with a value of 50.49 and round it to 1 decimal and it worked as expected and I got 50.5. Here is the table with values:

enter image description here

enter image description here

enter image description here

I am not sure what was going wrong in your case. I used the exact version of QGIS 3.4.2.


You are right. If I use negative latitude and longitude, I got strange results. I think this is a bug in QGIS 3.4.2. You should report this as a bug in QGIS 3.4.2 to the QGIS developer team here:

enter image description here

Update 2

The issue of rounding negative values was fixed in the latest stable release of QGIS 3.4.4-3. Now rounding negative numbers produces correct results:

enter image description here

  • Thank you very much for your response, I am creating a new grid in a new project to find the solution, but the problem persists. However, I am realizing that the problem does not arise if I create the grid in positive latitude and longitude coordinates. Could you try it in negative coordinates (South and West)? Dec 21, 2018 at 2:07
  • @GabrielDeLuca You are right, I updated my answer.
    – ahmadhanb
    Dec 21, 2018 at 2:25
  • Thank you @ahmadhanb, I just opened this bug report. Dec 21, 2018 at 3:05
  • This issue was already fixed in the latest stable version 3.4.4-3, if you want to update your answer I can accept it. Feb 14, 2019 at 19:29
  • I have updated my answer. Thank you for updating me about the issue.
    – ahmadhanb
    Feb 15, 2019 at 6:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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