[postgis-users] ST_GeomFromText vs ST_MakeEnvelope

Mike Toews mwtoews at gmail.com
Tue Oct 1 15:02:10 PDT 2013


On 2 October 2013 10:43, John Cartwright <john.c.cartwright at comcast.net> wrote:
> select name, ST_AsText(a.geom) as geom from cities a where a.geom &&
> ST_GeomFromText('POLYGON((-107 39, -102 39, -102 42, -17 42, -107 39))',
> 4326);

This geometry is not the geometry that you think it is...

postgis=# SELECT v.valid, v.reason, ST_AsText(v.location)
postgis-# FROM ST_IsValidDetail(
postgis(#   ST_GeomFromText('POLYGON((-107 39, -102 39, -102 42, -17
42, -107 39))', 4326)) AS v;
 valid |      reason       |          st_astext
-------+-------------------+------------------------------
 f     | Self-intersection | POINT(-102 39.1666666666667)
(1 row)


Try 'POLYGON((-107 39,-107 42,-102 42,-102 39,-107 39))' instead.

-Mike


More information about the postgis-users mailing list