[postgis-users] WKT/WKB Calculations
Paragon Corporation
lr at pcorp.us
Mon Sep 28 01:01:59 PDT 2009
The WKT truncates I think at about the 15th digit where as the wkb doesn't.
So yes you will lose information if you convert to WKT and have a lot of
decimal places.
Leo
-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Michael
Orlitzky
Sent: Sunday, September 27, 2009 10:39 PM
To: postgis-users at postgis.refractions.net
Subject: [postgis-users] WKT/WKB Calculations
I noticed that some error is introduced when converting from WKB to WKT (and
back). For example, the following computation of a polygon's area, divided
by itself, should return one:
SELECT (ST_Area(ST_GeomFromEWKB(ST_AsEWKB(tiger.the_geom)))
/ ST_Area(tiger.the_geom))
AS area_ratio
FROM tiger
area_ratio
-------------------
1
1
1
.
.
But when I convert to WKT as an intermediate format, the results get thrown
off by as much as 0.1% (I realize the first couple of rows don't show this,
but my tests break when the error passes that threshold):
SELECT (ST_Area(ST_GeomFromEWKT(ST_AsEWKT(tiger.the_geom)))
/ ST_Area(tiger.the_geom))
AS area_ratio
FROM tiger;
area_ratio
-------------------
1
1.00000014105231
1.00000017733961
1.00000021839733
1.00000004515224
etc.
Is this just a floating point limitation, or something else entirely?
_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
More information about the postgis-users
mailing list