4

I am using Shapely's wkt.dumps function to get WKT from geometry objects.

How do I limit the precision of the coordinates?

closed as off-topic by PolyGeo Aug 4 at 11:37

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "When seeking help to debug/write/improve code always provide the desired behavior, a specific problem/error and the shortest code (as formatted text, not pictures) needed to reproduce it in the question body. Providing a clear problem statement and a code attempt helps others to help you." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

11

Since Shapely 1.3 you can give dumps() a rounding_precision keyword arg:

>>> from shapely.geometry import Point
>>> from shapely.wkt import dumps
>>> dumps(Point(1.00000000000001, 0.0))
'POINT (1.00000000000001 0)'
>>> dumps(Point(1.00000000000001, 0.0), rounding_precision=4)
'POINT (1 0)'

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