Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change GeoJSON export precision to follow the GeoJSON spec #43783

Open
tjukanovt opened this issue Jun 18, 2021 · 5 comments
Open

Change GeoJSON export precision to follow the GeoJSON spec #43783

tjukanovt opened this issue Jun 18, 2021 · 5 comments
Labels
Data Provider Related to specific vector, raster or mesh data providers Feature Request

Comments

@tjukanovt
Copy link

Feature description.
Currently when a layer is exported to GeoJSON, QGIS sets the coordinate precision by default to 15, which is a bit too much
image

The GeoJSON spec recommends 6 decimal precision, which should be enough for 99% of use cases and helps to keep file sizes reasonable. User could then add the decimals if needed, but the default could be definitely lower than 15...

Additional context
What confuses me is that in the QgsJsonExpoer Class seems to have that 6 digits in it already: https://qgis.org/pyqgis/3.4/core/QgsJsonExporter.html

Maybe someone can ecplain the logic behind this?

Discussion about the topic started yesterday on Twitter in this thread.

@Joonalai
Copy link
Contributor

I will start working on a solution and PR for this.

@Joonalai
Copy link
Contributor

After investigating older and newer GeoJSON specs and GDAL GeoJSON driver documentation, I think that the default precision of 7 is way to go, since it is used as default precision in the GDAL driver for non-obsolete RFC 7946 spec.

@Rikuoja
Copy link

Rikuoja commented Jun 18, 2021

Looks like the value in the field is not actually used at all, unless the user explicitly changes the value. Instead, the default value of GDAL GeoJSON driver (15 or 7) is used.

If I set RFC7946 to YES and save the file, it is saved with precision 7, even though the box says 15. This looks like a bug to me.
Näyttökuva 2021-6-18 kello 11 31 59

Is there a reason why RFC7946=YES is not default? This would make 7 the default value.

@Joonalai
Copy link
Contributor

I created an issue to GDAL as well.

@kgjenkins
Copy link
Sponsor Contributor

Unfortunately the GDAL issue was closed without any change.

However, I still think that QGIS should default to RFC7946=YES, which would automatically set the COORDINATE_PRECISION to 7. Ideally, this value would show in the dialog, and also allow a user to update that value if desired, overriding the RFC7946 default.

Most users today who are exporting to GeoJSON format likely assume that they are exporting to a format based on the current standard (RFC7946) that has been in place since 2016, and not the deprecated specification from 2008.

@gioman gioman added the Data Provider Related to specific vector, raster or mesh data providers label Aug 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Data Provider Related to specific vector, raster or mesh data providers Feature Request
Projects
None yet
Development

No branches or pull requests

5 participants