Harasty, Daniel J
2016-06-23 12:36:44 UTC
I have an application where the full WKT representation of double-precision floats is undesirable.
It seems that WKTWriter has an optional, keyword argument to set the "rounding_precision". Great! Just what I need!
However... I can't figure out the calling convention; the ".wkt" method of the shapely object is a PROPERTY... so although the "kwargs" is defined, I can't figure out the right Python syntax to USE them.
# as expected
# bummer: I'd like to use something this concise
# this is the result what I want; can it be done without expressly
# creating a WKTWriter()?
How can I pass the "rounding_precision" kwarg to the property getter?
Thanks,
Dan
It seems that WKTWriter has an optional, keyword argument to set the "rounding_precision". Great! Just what I need!
However... I can't figure out the calling convention; the ".wkt" method of the shapely object is a PROPERTY... so although the "kwargs" is defined, I can't figure out the right Python syntax to USE them.
from shapely.geometry import Polygon
p1 = Polygon([(0,0), (10.1, 0), (31./3, 10), (0, 10)])
print p1.wkt
POLYGON ((0 0, 10.1 0, 10.33333333333333 10, 0 10, 0 0))p1 = Polygon([(0,0), (10.1, 0), (31./3, 10), (0, 10)])
print p1.wkt
# as expected
print p1.wkt(rounding_precision=8)
TypeError: 'str' object is not callable# bummer: I'd like to use something this concise
from shapely.geos import lgeos, WKTWriter
writer = WKTWriter(lgeos, rounding_precision=8)
print writer.write(p1)
POLYGON ((0 0, 10.1 0, 10.333333 10, 0 10, 0 0))writer = WKTWriter(lgeos, rounding_precision=8)
print writer.write(p1)
# this is the result what I want; can it be done without expressly
# creating a WKTWriter()?
How can I pass the "rounding_precision" kwarg to the property getter?
Thanks,
Dan