[postgis-tickets] [PostGIS] #4506: ST_Within wrong results

PostGIS trac at osgeo.org
Wed Sep 11 08:01:53 PDT 2019


#4506: ST_Within wrong results
------------------------------------+---------------------------
 Reporter:  georamos                |      Owner:  pramsey
     Type:  defect                  |     Status:  new
 Priority:  medium                  |  Milestone:  PostGIS 2.4.9
Component:  postgis                 |    Version:  2.4.x
 Keywords:  st_within wrong result  |
------------------------------------+---------------------------
 Hello all.

 I have a set of points and a polygon and want to select the points that
 are within the area. Both layers are in the same projection (WGS84 - EPSG:
 4326) and are valid.

 To determine wich points are within the area i'm using ST_WITHIN but the
 function is returning elements that are not within an area.
 You can run this query to test it out:


 {{{
 with points as (
     select
 ST_Transform('0104000020E61000000100000001010000009B8BBFED094A22C0C8CA2F83315C4340'::geometry,
 4326) as geom
     union
     select
 ST_Transform('0104000020E61000000100000001010000007C5EF1D4237522C0D0E5CDE15A614340'::geometry,
 4326) as geom
 ), area as (
     select
 ST_Transform('0106000020E610000001000000010300000001000000380000009AEE75525F2E22C0E8887C9752614340EE974F560C2F22C0E529ABE97A6043400D6C9560713022C0A585CB2A6C604340A643A7E7DD3022C0FCC74274086043405378D0ECBA2F22C0F29881CAF85F4340570A815CE23022C068E6C93505604340E12879758E3122C0D09A1F7F695F43404EB7EC10FF3022C023A46E675F5F4340B456B439CE3522C0342C465D6B5D4340D9EBDD1FEF3522C03ACD02ED0E5D43403E97A949F03E22C0707CED99255B43405859DB148F4322C0469A7807785A434052651877835022C0F374AE28255A4340A05225CADE5222C0E71890BDDE594340357A3540695022C00C23BDA8DD594340E99E758D965322C097FDBAD39D5943403048FAB48A6E22C059BE2EC37F584340B03A72A4337022C0889FFF1EBC5843403A083A5AD57222C078962023A05843400DE36E10AD7522C01EFF058200594340C32B499EEB7322C02DB0C7444A594340177E703E757422C06FF607CA6D594340A4367172BF7322C0CA15DEE5225A4340D80FB1C1C27122C05AA148F7735A43401FD95C35CF7122C0EA92718C645B4340D0471971017022C086915ED4EE5B43405114E813796A22C06478EC67B15C4340F1F109D9796B22C0BF805EB8735D43402979758E016922C042791F47735E4340F2B1BB40496922C083328D26175F4340C8B3CBB73E6C22C039B35DA10F60434036ACA92C0A6B22C090BE49D3A06043403FC91D36916922C0B7973446EB604340D7BFEB33676522C0A4552DE928614340E6CFB7054B6522C0D2E5CDE15A614340CC7B9C69C26622C03D44A33B8861434005172B6A306522C002BA2F67B661434073F38DE89E6522C0BC74931804624340C5AD8218E86222C02BBEA1F0D962434068D0D03FC15D22C06FBBD05CA763434048179B560A5922C0EE26F8A6E96343407768588CBA5622C0417FA1478C644340535E2BA1BB5422C06CB41CE8A16443401171732A195022C03EB2B96A9E6543402E20B41EBE4C22C005323B8BDE654340A9C29FE1CD4A22C0DBA50D87A56543408DD2A57F494A22C0923CD7F7E164434008AF5DDA704022C0DDEEE53E396443404FAC53E57B3E22C01EFB592C4564434071395E81E83922C0202A8D98D9634340698D4127843622C0541C075E2D6343404548DDCEBE3222C0B20DDC813A63434036ACA92C0A3322C03C50A73CBA6343400EDAAB8F872E22C097361C96066443402CF180B2292F22C0FFE89B340D6243409AEE75525F2E22C0E8887C9752614340'::geometry,
 4326) as geom
 )
 SELECT points.*, ST_Within(points.geom,area.geom), ST_IsValid(points.geom)
 valid_point, ST_IsValid(area.geom) valid_area
 from points, area
 where ST_Within(points.geom,area.geom);
 }}}

 Odd enough, if you test it with only one point at a time, the result is
 correct, but if you use both point the result is wrong.

-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/4506>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list