[postgis-users] problem with points in polygon edge
Gustavo Martinez
gmpuljak at yahoo.com.ar
Wed Mar 16 10:27:32 PDT 2022
Hi Greg,
El 15/3/22 a las 20:08, Greg Troxel escribió:
> Gustavo Martinez<gmpuljak at yahoo.com.ar> writes:
>
>> attached you can see an example of the situation. I am interested in
>> all the points. The arrow indicates one point that lays on the edge of
>> polygon 1 and polygon 2.
> Ah, now I understand that you are trying to use polygons that have
> overlapping edges and that you further want each point to be assigned to
> exactly one polygon.
>
>> If I use st_within(), that point is not counted in either polygon, but
>> if I use st_intersects() it is counted in both polygons. For that
>> reason, I wrote the function.
>> The data comes from a VMS device, that reports the GPS position, along
>> speed and vessel ID with a fixed frequency.
>> Hope it is more clear now.
> The question is then what you are really trying to do. If you are
> trying to count all the points in the union of some polygons, you can
> union the polygons and then count. If you want to know how many points
> are in each polygon, with a definition of "in" that says
>
> a point is in a polygon if it is really in it, or if it is on the
> boundary and the point is not in some other polygon sharing the
> boundary, however it is arbitrary which polygon the piont is
> considered to be in
> with the stipulation that polygons do not really overlap, but just
> touch at outer edges.
I have two data sources: vessel positions (VMS) and logbooks with fish
landings for each trip. I developed an algorithm that links the catches
with some points that show "fishing behaviour". From this database
(point based), we get data at different spatial and temporal
aggregations (polygons). I need to consider all the points, either on
the boundaries or not. That's why I wrote the function, that has a fixed
criteria for the selection. The question is, can it be optimized? It is
quite slow.
On the other hand, it works for rectangular (lat-long) polygons, but I
don't know how to obtain this for irregular polygons (exclusive economic
zones, marine protected areas, etc.)
>
> You might consider a function that assigns points to polygons, perhaps
> taking the first member of selecting all polygons such that
> ST_Intersects(point, polygon) and assigning that in a table of points
> and assigned polygons, and then using that for your statistics.
>
> I guess you could also think about a function like ST_HalfOpenIntersect but
> that somehow treats each edge as either a closed or open interval
> depending on angle, so that points on shared edges would end up matching
> one and not the other.
--
*Gustavo Martínez Puljak*
*
*cel: +549 11 64089000
Linkedin:www.linkedin.com/in/gustavomartinezpuljak
<https://www.linkedin.com/in/gustavomartinezpuljak>
*
*/Que la tierra se vaya haciendo camino ante tus pasos,//
//que el viento sople siempre a tus espaldas,//
//que el sol brille cálido sobre tu cara,//
//que la lluvia caiga suavemente sobre tus campos y,//
//hasta tanto volvamos a encontrarnos,//
//que Dios te lleve en la palma de su mano./
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20220316/9437d1e3/attachment.html>
More information about the postgis-users
mailing list