Using "QGIS 2.0.1-Dufour", I try to convert a vector layer into GEOJSON file using "Save As" sub menu. I get the GEOJSON file, but the coordinates of points have values up to 15 decimal places.

How can I round off the values at the desired number of decimal places?

2 Answers 2


I don't know if it is possible to limit the number of the coordinates' values when you save a vector layer as a GeoJSON file, using QGIS, but I'll show you an alternative way using a simple (but powerful) text editor: Notepad++.

Of course, you can use any similar software you like, only assure yourself it can perform search an replace using regular expressions.

Assuming you have already the GeoJSON file, just open it using Notepad++:

enter image description here

Then go to Search > Replace and use these expressions:

in the Find what field:


and in the Replace with field:


enter image description here

(Remember that Regular expression must be checked)

This is the result after pressing Replace all:

enter image description here

If you want a different number of decimals just replace {2} with the new desired value:

enter image description here

  • Very tricky way of solving a problem. Appreciate your suggestion. Feb 17, 2014 at 7:29
  • As highlighted by another user (in an aswer), it is worthwhile to note that this method does not round off but truncate the decimals.
    – fatih_dur
    Feb 17, 2017 at 14:36

It's very easy to limit the coordinates when exporting GeoJson, as QGIS just uses the ogr2ogr program for the export, and it allows you to pass in additional parameters when you save the file. Here's a pic:

enter image description here

That will ensure only 2 decimal places in the coordinates.

  • 1
    Newer Qgis versions have this option.
    – neogeomat
    May 24, 2015 at 0:54
  • 1
    Just to round up @chrismarx question. You can also do it by the command line by adding a creation option to your ogr2ogr statement: ogr2ogr -f GeoJSON -dsco "COORDINATE_PRECISION=6" output.json input.shp -progress
    – Valentin
    Mar 26, 2017 at 20:22
  • 1
    @Valentin - must use -lco, not -dsco in ogr2ogr.\\ ogr2ogr -f GeoJSON -lco COORDINATE_PRECISION=6
    – Tybion
    Dec 31, 2019 at 22:22

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.