[postgis-users] st_astext() created invalid

Brian Peschel brianp at occinc.com
Thu Jul 21 08:06:36 PDT 2016


Ack, I forgot version information:
SELECT version() || ' '  || postgis_full_version();
?column?
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  PostgreSQL 9.3.13 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu 
4.8.4-2ubuntu1~14.04.1) 4.8.4, 64-bit POSTGIS="2.1.2 r12389" 
GEOS="3.4.2-CAPI-1.8.2 r3921" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 
1.10.1, released 2013/08/26" LIBXML="2.9.1" LIBJSON="UNKNOWN" TOPOLOGY 
RASTER
(1 row)

- brian

On 07/21/2016 10:04 AM, Brian wrote:
> Not sure I understand what is happening here.
>
> I have a geom:
> select * from my_temp ;
> geom
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>  0103000020AD100000010000000B0000006D514CC326AC57C029776BF2CF214440B742588D25AC57C0D7F84CF6CF2144406E514CC326AC57C029776BF2CF21444015CCF33B28AC57C084FAF1F2CF2144405748540328AC57C096010C70E621444090EC5BF720AC57C0D8C2876DE62144409C3B551921AC57C0AFFE19EFD8214440F555A82421AC57C0043D2F70D42144401508BE2F21AC57C07110D308D02144404E70FB2F21AC57C0C5BB6DF0CF2144406D514CC326AC57C029776BF2CF214440
>
> Which PostGIS says is valid:
> select st_isvalid(geom) from my_temp ;
>  st_isvalid
> ------------
>  t
> (1 row)
>
> I then convert to a format I can read:
> select st_astext(geom) from my_temp ;
> st_astext
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>  POLYGON((-94.6898658986372 40.2641585373625,-94.689792 
> 40.264159,-94.6898658986372 40.2641585373625,-94.6899557 
> 40.2641586,-94.6899422 40.2648449,-94.6895121 40.2648446,-94.6895202 
> 40.2644328,-94.6895229 40.2642956,-94.6895255428102 
> 40.2641612082088,-94.6895256 40.2641583,-94.6898658986372 
> 40.2641585373625))
> (1 row)
>
> But that isn't valid.  It is self intersecting (point 1 and point 3 
> repeat).  And if I check the validity of the st_astext version:
> select st_isvalid(geom), st_isvalid(st_geomfromtext(st_astext(geom), 
> 4269)) from my_temp;
> NOTICE:  Self-intersection at or near point -94.689865898637194 
> 40.264158537362498
>  st_isvalid | st_isvalid
> ------------+------------
>  t          | f
> (1 row)
>
> Any idea what is going on here and how can I prevent it?
>
> TIA!
> - brian

-- 
Brian Peschel
One Call Concepts, Inc
Systems Division

Voice: 414-259-1047 ext. 93
Fax: 414-777-3666

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20160721/e66e13c1/attachment.html>


More information about the postgis-users mailing list