[postgis-users] problem with points in polygon edge

Greg Troxel gdt at lexort.com
Mon Mar 14 07:41:32 PDT 2022


Gustavo Martinez <gmpuljak at yahoo.com.ar> writes:

> Hi all,
>
> I am working with fishing vessels positions. I have millions of
> points, and when doing some analysis I need to do some intersections
> with polygons.
>
> All the database is on EPSG 4326 (Lat Long)
>
> I've noticed some problems when the points are on the edges of the
> polygons. When I use ST_Within I lose the points on the edges, while
> when using ST_Intersects those points get counted twice.

I would suggest figuring out what is wrong with the queries that ought
to make sense and fixing that instead of trying to code a function that
behaves like that and then optimizing that funciton.


You say "lose points on the edge", but you did not post your query and
you did not post a sample point that is mishandled.

Do you mean something like a pseudo-square from say 40-41N, 20-21E and a
point that is 40.5N 20E and wanting that to be included in ST_Within?
If you don't mean that please explain precisely.

I also don't understand "with ST_Intersects I get duplicates", but again
you didn't post your query or sample data.

It seems like if you want to select  all vessel points within some
polyon (including points that are on the edge), ST_Intersects should be
want you want.


I would also wonder why you care about points that are strictly on the
polygon.  First, boats are not points, but I am guessing you have "Boat
Reference Position", perhaps implicitly a GPS antenna.

All measurements have error, and thus for any actual boat
position near the polygon edge, a recorded position could be inside or
outside.  So worrying that a position exactly on the line numerically --
which seems pretty unlikely with real data of high -- is not something
that I understand.

Hope this helps,
Greg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20220314/eb70aeb9/attachment.sig>


More information about the postgis-users mailing list