You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think decimal numbers should be kept as it is by default , and we can optionally specify precision.
I wonder which kind of use cases people want to round decimal numbers when they use geojson library.
The text was updated successfully, but these errors were encountered:
I've been thinking about this question, which is a good one. I think there are a couple of parts to your question, so I am attempting to break them down the best I can. Please clarify as needed:
When you create a co-ordinate with a value such as Point((1e-9,0)) the 1e-9 is a "Real" number, stored as an object of type "float". Python's native round() function applies on that object and provides a representation of that fraction as best as it can following the rules and limitations of Floating Point Arithmetic.
The geojson instance functions offer a way to change the precision of round function used in python. This will allow you to preserve the decimal coordinates you need. Example...
>>> p = geojson.Point((1e-9,0),precision=9)
{"coordinates": [1e-09, 0], "type": "Point"}
With regards to why DEFAULT_PRECISION = 6, I believe this has to do with interoperability considerations in the GeoJSON RFC 7946 Sec 11.2. A precision of 6 lies offers a representation of ~10cm in Lat/Lon co-ordinates. This is deemed good enough for major surveying activities, and adequate precision to exchange information in. A very good article was posted on GIS Stackexchange about the impact of precision in GPS coordinates, which someone who is interested can read here
Issues
By default
DEFAULT_PRECISION = 6
and instantiatingPoint
class rounds decimal number like below.Proposal
I think decimal numbers should be kept as it is by default , and we can optionally specify precision.
I wonder which kind of use cases people want to round decimal numbers when they use geojson library.
The text was updated successfully, but these errors were encountered: