Re: [postgis-users] Difficult Problem with Polygons
Hi, 1. Does st_touches not work for that ? 2. What do you mean by below ? south from the line ? St_distance should help you to find the closer one from Q. Hugues. Message d'origine De: postgis-users-boun...@postgis.refractions.net de la part de Ed Linde Date: lun. 29/10/2012 09:33 À: PostGIS Users Discussion Objet : [postgis-users] Difficult Problem with Polygons Hi All, I need help with 2 hard problems. I store triangles in a table as POLYGON. 1. I want to know for a given triangle, which triangles share an edge (adjacent) with this triangle. 2. Then I have a line that cuts through a triangle's face and a point Q, away from this line and triangle. I would like to know amongst the neighbours of the triangle (calculated in 1), which ones fall *below* the line and closer to the point Q (where Q is the generator of a Voronoi cell). And also the set of triangles that are *above* the line and further from Q. Any suggestions as to how I can go about achieving this in postgis 2.0? Cheers, Ed winmail.dat___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Difficult Problem with Polygons
On 29 October 2012 21:33, Ed Linde edoli...@gmail.com wrote: Hi All, I need help with 2 hard problems. I store triangles in a table as POLYGON. 1. I want to know for a given triangle, which triangles share an edge (adjacent) with this triangle. Sounds like you have a finite element mesh with nodes and elements. You can use ST_Relate with pattern 'FF2F11212' to pick out elements that share the same edge. This DE-9-IM is sort-of a custom ST_Touches, but only takes linear boundary overlaps. So if you have a table elements, and you want to find ones that touch ID 567: SELECT elements.* FROM elements, elements as e WHERE e.id = 567 AND ST_Relate(elements.geom, e.geom, 'FF2F11212'); I'm not certain about your second question. -Mike ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Difficult Problem with Polygons
Hi All, Thanks for the suggestions. For 1) I will look into how ST_touches works and see if it can pick up all the adjacent polygons to the one I have. And also look into Mike's suggestion on ST_relate...though I must admit it looks more complex. For 2) I will try to clarify it a bit more... its harder to do without a figure :) but here goes. Lets say we have a point Q which is the generator of a voronoi cell. Now I compute the intersection between the voronoi cell boundaries and my triangulation (Set of polygons) using ST_intersect. Once I have these triangles.. I say pick one triangle T that is intersecting the voronoi cell boundary of Q. For all the triangles adjacent to T, I need to know which triangles are INSIDE the voronoi boundary (closer to Q) and which adjacent triangles are just OUTSIDE the voronoi boundary (farther from Q). I am basically testing for a certain property by shrinking the voronoi cell (closer to Q) and another property when expanding the voronoi cell (away from Q). Just need to make this division of triangles. Haven't thought of a nice way to do this in postgis 2.0 So any suggestions would greatly help. Thanks, Ed On Mon, Oct 29, 2012 at 10:15 AM, Mike Toews mwto...@gmail.com wrote: On 29 October 2012 21:33, Ed Linde edoli...@gmail.com wrote: Hi All, I need help with 2 hard problems. I store triangles in a table as POLYGON. 1. I want to know for a given triangle, which triangles share an edge (adjacent) with this triangle. Sounds like you have a finite element mesh with nodes and elements. You can use ST_Relate with pattern 'FF2F11212' to pick out elements that share the same edge. This DE-9-IM is sort-of a custom ST_Touches, but only takes linear boundary overlaps. So if you have a table elements, and you want to find ones that touch ID 567: SELECT elements.* FROM elements, elements as e WHERE e.id = 567 AND ST_Relate(elements.geom, e.geom, 'FF2F11212'); I'm not certain about your second question. -Mike ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Difficult Problem with Polygons
Hi All, Wondering if that diagram made things any simpler or is it still not clear what the problem is? Thanks, Ed On Mon, Oct 29, 2012 at 11:57 AM, Ed Linde edoli...@gmail.com wrote: Attached is a figure. Where the dotted line is the boundary of the voronoi cell whose generator is point P1. So triangle 4 intersects with the voronoi boundary, but we are interested in the adjacent triangles of triangle 4, which are closer to point P1. For example, triangle 5. Hope this helps. Cheers, Ed On Mon, Oct 29, 2012 at 11:50 AM, Nicolas Ribot nicolas.ri...@gmail.comwrote: Could you draw a figure ? Nicolas On 29 October 2012 11:03, Ed Linde edoli...@gmail.com wrote: Hi All, Thanks for the suggestions. For 1) I will look into how ST_touches works and see if it can pick up all the adjacent polygons to the one I have. And also look into Mike's suggestion on ST_relate...though I must admit it looks more complex. For 2) I will try to clarify it a bit more... its harder to do without a figure :) but here goes. Lets say we have a point Q which is the generator of a voronoi cell. Now I compute the intersection between the voronoi cell boundaries and my triangulation (Set of polygons) using ST_intersect. Once I have these triangles.. I say pick one triangle T that is intersecting the voronoi cell boundary of Q. For all the triangles adjacent to T, I need to know which triangles are INSIDE the voronoi boundary (closer to Q) and which adjacent triangles are just OUTSIDE the voronoi boundary (farther from Q). I am basically testing for a certain property by shrinking the voronoi cell (closer to Q) and another property when expanding the voronoi cell (away from Q). Just need to make this division of triangles. Haven't thought of a nice way to do this in postgis 2.0 So any suggestions would greatly help. Thanks, Ed On Mon, Oct 29, 2012 at 10:15 AM, Mike Toews mwto...@gmail.com wrote: On 29 October 2012 21:33, Ed Linde edoli...@gmail.com wrote: Hi All, I need help with 2 hard problems. I store triangles in a table as POLYGON. 1. I want to know for a given triangle, which triangles share an edge (adjacent) with this triangle. Sounds like you have a finite element mesh with nodes and elements. You can use ST_Relate with pattern 'FF2F11212' to pick out elements that share the same edge. This DE-9-IM is sort-of a custom ST_Touches, but only takes linear boundary overlaps. So if you have a table elements, and you want to find ones that touch ID 567: SELECT elements.* FROM elements, elements as e WHERE e.id = 567 AND ST_Relate(elements.geom, e.geom, 'FF2F11212'); I'm not certain about your second question. -Mike ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Difficult Problem with Polygons
Yes indeed it's clearer. You could compute the distance between each adjacent triangle and the voronoi generator and order by shortest distance. (taking the triangle's centroid for the distance) Also, is the voronoi boundary forming a polygon or just a line ? in the former, you could find all the triangles inside the voronoi cell. In the latter, you will have to determine a signed area or a cross product to know if points lie in the same side of the boundary. Nicolas On 29 October 2012 13:45, Ed Linde edoli...@gmail.com wrote: Hi All, Wondering if that diagram made things any simpler or is it still not clear what the problem is? Thanks, Ed On Mon, Oct 29, 2012 at 11:57 AM, Ed Linde edoli...@gmail.com wrote: Attached is a figure. Where the dotted line is the boundary of the voronoi cell whose generator is point P1. So triangle 4 intersects with the voronoi boundary, but we are interested in the adjacent triangles of triangle 4, which are closer to point P1. For example, triangle 5. Hope this helps. Cheers, Ed On Mon, Oct 29, 2012 at 11:50 AM, Nicolas Ribot nicolas.ri...@gmail.com wrote: Could you draw a figure ? Nicolas On 29 October 2012 11:03, Ed Linde edoli...@gmail.com wrote: Hi All, Thanks for the suggestions. For 1) I will look into how ST_touches works and see if it can pick up all the adjacent polygons to the one I have. And also look into Mike's suggestion on ST_relate...though I must admit it looks more complex. For 2) I will try to clarify it a bit more... its harder to do without a figure :) but here goes. Lets say we have a point Q which is the generator of a voronoi cell. Now I compute the intersection between the voronoi cell boundaries and my triangulation (Set of polygons) using ST_intersect. Once I have these triangles.. I say pick one triangle T that is intersecting the voronoi cell boundary of Q. For all the triangles adjacent to T, I need to know which triangles are INSIDE the voronoi boundary (closer to Q) and which adjacent triangles are just OUTSIDE the voronoi boundary (farther from Q). I am basically testing for a certain property by shrinking the voronoi cell (closer to Q) and another property when expanding the voronoi cell (away from Q). Just need to make this division of triangles. Haven't thought of a nice way to do this in postgis 2.0 So any suggestions would greatly help. Thanks, Ed On Mon, Oct 29, 2012 at 10:15 AM, Mike Toews mwto...@gmail.com wrote: On 29 October 2012 21:33, Ed Linde edoli...@gmail.com wrote: Hi All, I need help with 2 hard problems. I store triangles in a table as POLYGON. 1. I want to know for a given triangle, which triangles share an edge (adjacent) with this triangle. Sounds like you have a finite element mesh with nodes and elements. You can use ST_Relate with pattern 'FF2F11212' to pick out elements that share the same edge. This DE-9-IM is sort-of a custom ST_Touches, but only takes linear boundary overlaps. So if you have a table elements, and you want to find ones that touch ID 567: SELECT elements.* FROM elements, elements as e WHERE e.id = 567 AND ST_Relate(elements.geom, e.geom, 'FF2F11212'); I'm not certain about your second question. -Mike ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Difficult Problem with Polygons
Hi Ed, Well if clarifies one thing at least, you can ignore Mike's st_Relate because 5 is not adjacent to a linear edge, it is only adjacent to a vertex, so st_touches should work fine. so you are looking for: 1. a specific triangle by id 2. that intersects triangle VC 3. and the triangles adjacent to triangle by id 4. and those that are contained in VC 5. sorted by distance to P1 limit 1 so something like: select id, the_geom from (select id, the_geom as adjacent from triangles where st_touches(the_geom, (select the_geom from triangles a, (select the_geom as vc from vc_table where id='p1') b where a.id=4)) c order by st_distance(c.the_geom, (select the_geom from points where id='p1')) asc limit 1; Untested, but should give you a model to work with. -Steve W On 10/29/2012 6:57 AM, Ed Linde wrote: Attached is a figure. Where the dotted line is the boundary of the voronoi cell whose generator is point P1. So triangle 4 intersects with the voronoi boundary, but we are interested in the adjacent triangles of triangle 4, which are closer to point P1. For example, triangle 5. Hope this helps. Cheers, Ed On Mon, Oct 29, 2012 at 11:50 AM, Nicolas Ribot nicolas.ri...@gmail.com mailto:nicolas.ri...@gmail.com wrote: Could you draw a figure ? Nicolas On 29 October 2012 11:03, Ed Linde edoli...@gmail.com mailto:edoli...@gmail.com wrote: Hi All, Thanks for the suggestions. For 1) I will look into how ST_touches works and see if it can pick up all the adjacent polygons to the one I have. And also look into Mike's suggestion on ST_relate...though I must admit it looks more complex. For 2) I will try to clarify it a bit more... its harder to do without a figure :) but here goes. Lets say we have a point Q which is the generator of a voronoi cell. Now I compute the intersection between the voronoi cell boundaries and my triangulation (Set of polygons) using ST_intersect. Once I have these triangles.. I say pick one triangle T that is intersecting the voronoi cell boundary of Q. For all the triangles adjacent to T, I need to know which triangles are INSIDE the voronoi boundary (closer to Q) and which adjacent triangles are just OUTSIDE the voronoi boundary (farther from Q). I am basically testing for a certain property by shrinking the voronoi cell (closer to Q) and another property when expanding the voronoi cell (away from Q). Just need to make this division of triangles. Haven't thought of a nice way to do this in postgis 2.0 So any suggestions would greatly help. Thanks, Ed On Mon, Oct 29, 2012 at 10:15 AM, Mike Toews mwto...@gmail.com mailto:mwto...@gmail.com wrote: On 29 October 2012 21:33, Ed Linde edoli...@gmail.com mailto:edoli...@gmail.com wrote: Hi All, I need help with 2 hard problems. I store triangles in a table as POLYGON. 1. I want to know for a given triangle, which triangles share an edge (adjacent) with this triangle. Sounds like you have a finite element mesh with nodes and elements. You can use ST_Relate with pattern 'FF2F11212' to pick out elements that share the same edge. This DE-9-IM is sort-of a custom ST_Touches, but only takes linear boundary overlaps. So if you have a table elements, and you want to find ones that touch ID 567: SELECT elements.* FROM elements, elements as e WHERE e.id http://e.id = 567 AND ST_Relate(elements.geom, e.geom, 'FF2F11212'); I'm not certain about your second question. -Mike ___ postgis-users mailing list postgis-users@postgis.refractions.net mailto:postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net mailto:postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net mailto:postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net
Re: [postgis-users] Difficult Problem with Polygons
Hi All, I was trying to do this intersection between two tables, I have inserted the selects for the two tables and the error. Also the postgis full version information. Is there a way to get around this problem? Is this a bug? The polygons in both tables contain 3D points. Could this be a problem? Cheers, Ed select a.id, ST_AsText(st_intersection(a.geomtext, b.geomtext)) the_tris from small_tris a, vfaces b where st_intersects (a.geomtext, b.geomtext); ERROR: Error performing intersection: TopologyException: found non-noded intersection between LINESTRING (593907 5.2196e+06, 593915 5.21961e+06) and LINESTRING (593911 5.21961e+06, 593908 5.2196e+06) at 593908.598 5219602 809.899918 ** Error ** ERROR: Error performing intersection: TopologyException: found non-noded intersection between LINESTRING (593907 5.2196e+06, 593915 5.21961e+06) and LINESTRING (593911 5.21961e+06, 593908 5.2196e+06) at 593908.598 5219602 809.899918 SQL state: XX000 SELECT PostGIS_full_version(); postgis_full_version --- POSTGIS=2.0.0alpha7SVN GEOS=3.3.2-CAPI-1.7.2 PROJ=Rel. 4.7.1, 23 September 2009 GDAL=GDAL 1.9.0, released 2011/12/29 LIBXML=2.7.8 USE_STATS (1 row) bounds=# select gen_id, ST_AsText(geomtext) from vfaces; gen_id | st_astext +- 7 | POLYGON Z ((593908 5219600 803,593907 5219600 818,593915 5219610 818,593911 5219610 803,593908 5219600 803)) 7 | POLYGON Z ((593908 5219600 803,593899 5219600 803,593899 5219600 818,593907 5219600 818,593908 5219600 803)) 7 | POLYGON Z ((593908 5219600 803,593911 5219610 803,593903 5219620 803,593899 5219620 803,593899 5219600 803,593908 5219600 803)) 7 | POLYGON Z ((593899 5219620 803,593899 5219620 818,593899 5219600 818,593899 5219600 803,593899 5219620 803)) 7 | POLYGON Z ((593899 5219620 803,593903 5219620 803,593912 5219620 818,593899 5219620 818,593899 5219620 803)) 7 | POLYGON Z ((593912 5219620 818,593903 5219620 803,593911 5219610 803,593915 5219610 818,593912 5219620 818)) 7 | POLYGON Z ((593912 5219620 818,593915 5219610 818,593907 5219600 818,593899 5219600 818,593899 5219620 818,593912 5219620 818)) 16 | POLYGON Z ((593921 5219600 803,593921 5219610 803,593911 5219610 803,593908 5219600 803,593921 5219600 803)) 16 | POLYGON Z ((593921 5219600 803,593921 5219600 818,593921 5219610 818,593921 5219610 803,593921 5219600 803)) 16 | POLYGON Z ((593921 5219600 803,593908 5219600 803,593907 5219600 818,593921 5219600 818,593921 5219600 803)) 16 | POLYGON Z ((593911 5219610 803,593921 5219610 803,593921 5219610 818,593915 5219610 818,593911 5219610 803)) 16 | POLYGON Z ((593911 5219610 803,593915 5219610 818,593907 5219600 818,593908 5219600 803,593911 5219610 803)) 16 | POLYGON Z ((593907 5219600 818,593915 5219610 818,593921 5219610 818,593921 5219600 818,593907 5219600 818)) 18 | POLYGON Z ((593921 5219610 803,593911 5219610 803,593915 5219610 818,593921 5219610 818,593921 5219610 803)) 18 | POLYGON Z ((593921 5219610 803,593921 5219620 803,593903 5219620 803,593911 5219610 803,593921 5219610 803)) 18 | POLYGON Z ((593921 5219610 803,593921 5219610 818,593921 5219620 818,593921 5219620 803,593921 5219610 803)) 18 | POLYGON Z ((593912 5219620 818,593915 5219610 818,593911 5219610 803,593903 5219620 803,593912 5219620 818)) 18 | POLYGON Z ((593912 5219620 818,593921 5219620 818,593921 5219610 818,593915 5219610 818,593912 5219620 818)) 18 | POLYGON Z ((593912 5219620 818,593903 5219620 803,593921 5219620 803,593921 5219620 818,593912 5219620 818)) (19 rows) bounds=# select id, st_astext(geomtext) from small_tris; id | st_astext +--- 0 | POLYGON Z ((593890 5219590 840,593900 5219590 827,593890 5219600 817,593890 5219590 840)) 1 | POLYGON Z ((593890 5219600 817,593900 5219590 827,593900 5219600 815,593890 5219600 817)) 2 | POLYGON Z ((593900 5219600 815,593910 5219590 824,593910 5219600 815,593900 5219600 815)) 3 | POLYGON Z ((593910 5219590 824,593900 5219600 815,593900 5219590 827,593910 5219590 824)) 4 | POLYGON Z ((593910 5219600 815,593910 5219590 824,593920 5219590 842,593910 5219600 815)) 5 | POLYGON Z ((593900 5219600 815,593910 5219600 815,593900 5219610 815,593900 5219600 815)) 6 | POLYGON Z ((593890 5219600 817,593900 5219600 815,593900 5219610 815,593890 5219600 817)) 7 | POLYGON Z ((593890 5219620 812,593890 5219610 825,593900 5219610 815,593890 5219620 812)) 8 | POLYGON Z ((593890 5219630 827,593890 5219620 812,593900 5219620 841,593890 5219630 827)) 9 | POLYGON Z ((593900 5219610 815,593900 5219620 841,593890
Re: [postgis-users] Difficult Problem with Polygons
If the points are computed in the right order, you can store them and pass them to st_makeLine and st_makePolygon. If not, you can form a segment between 2 closest points and connect it to the closest points. On 29 October 2012 15:37, Ed Linde edoli...@gmail.com wrote: Hi All, Thanks for the tips! Just another thing, when I compute the transition points on each edge (shown as red points in my pdf). I need to join them to make a polygon. Wondering how I can connect them together so that I start with a point and end on it to form a closed polygon? Cheers, Ed On Mon, Oct 29, 2012 at 3:03 PM, Stephen Woodbridge wood...@swoodbridge.com wrote: Hi Ed, Well if clarifies one thing at least, you can ignore Mike's st_Relate because 5 is not adjacent to a linear edge, it is only adjacent to a vertex, so st_touches should work fine. so you are looking for: 1. a specific triangle by id 2. that intersects triangle VC 3. and the triangles adjacent to triangle by id 4. and those that are contained in VC 5. sorted by distance to P1 limit 1 so something like: select id, the_geom from (select id, the_geom as adjacent from triangles where st_touches(the_geom, (select the_geom from triangles a, (select the_geom as vc from vc_table where id='p1') b where a.id=4)) c order by st_distance(c.the_geom, (select the_geom from points where id='p1')) asc limit 1; Untested, but should give you a model to work with. -Steve W On 10/29/2012 6:57 AM, Ed Linde wrote: Attached is a figure. Where the dotted line is the boundary of the voronoi cell whose generator is point P1. So triangle 4 intersects with the voronoi boundary, but we are interested in the adjacent triangles of triangle 4, which are closer to point P1. For example, triangle 5. Hope this helps. Cheers, Ed On Mon, Oct 29, 2012 at 11:50 AM, Nicolas Ribot nicolas.ri...@gmail.com mailto:nicolas.ri...@gmail.com wrote: Could you draw a figure ? Nicolas On 29 October 2012 11:03, Ed Linde edoli...@gmail.com mailto:edoli...@gmail.com wrote: Hi All, Thanks for the suggestions. For 1) I will look into how ST_touches works and see if it can pick up all the adjacent polygons to the one I have. And also look into Mike's suggestion on ST_relate...though I must admit it looks more complex. For 2) I will try to clarify it a bit more... its harder to do without a figure :) but here goes. Lets say we have a point Q which is the generator of a voronoi cell. Now I compute the intersection between the voronoi cell boundaries and my triangulation (Set of polygons) using ST_intersect. Once I have these triangles.. I say pick one triangle T that is intersecting the voronoi cell boundary of Q. For all the triangles adjacent to T, I need to know which triangles are INSIDE the voronoi boundary (closer to Q) and which adjacent triangles are just OUTSIDE the voronoi boundary (farther from Q). I am basically testing for a certain property by shrinking the voronoi cell (closer to Q) and another property when expanding the voronoi cell (away from Q). Just need to make this division of triangles. Haven't thought of a nice way to do this in postgis 2.0 So any suggestions would greatly help. Thanks, Ed On Mon, Oct 29, 2012 at 10:15 AM, Mike Toews mwto...@gmail.com mailto:mwto...@gmail.com wrote: On 29 October 2012 21:33, Ed Linde edoli...@gmail.com mailto:edoli...@gmail.com wrote: Hi All, I need help with 2 hard problems. I store triangles in a table as POLYGON. 1. I want to know for a given triangle, which triangles share an edge (adjacent) with this triangle. Sounds like you have a finite element mesh with nodes and elements. You can use ST_Relate with pattern 'FF2F11212' to pick out elements that share the same edge. This DE-9-IM is sort-of a custom ST_Touches, but only takes linear boundary overlaps. So if you have a table elements, and you want to find ones that touch ID 567: SELECT elements.* FROM elements, elements as e WHERE e.id http://e.id = 567 AND ST_Relate(elements.geom, e.geom, 'FF2F11212'); I'm not certain about your second question. -Mike ___ postgis-users mailing list
Re: [postgis-users] Difficult Problem with Polygons
Thanks Nicolas. Just about the error, is this because the line segments are too close and postgis 2.0 could not handle this? If so is there a workaround, even if it means slightly having to perturb each point's position to not run into this bug. I was really hoping that the intersection of two polygonal shapes in 3D would be fairly simple in postgis 2.0 :( Ed On Mon, Oct 29, 2012 at 4:00 PM, Nicolas Ribot nicolas.ri...@gmail.comwrote: If the points are computed in the right order, you can store them and pass them to st_makeLine and st_makePolygon. If not, you can form a segment between 2 closest points and connect it to the closest points. On 29 October 2012 15:37, Ed Linde edoli...@gmail.com wrote: Hi All, Thanks for the tips! Just another thing, when I compute the transition points on each edge (shown as red points in my pdf). I need to join them to make a polygon. Wondering how I can connect them together so that I start with a point and end on it to form a closed polygon? Cheers, Ed On Mon, Oct 29, 2012 at 3:03 PM, Stephen Woodbridge wood...@swoodbridge.com wrote: Hi Ed, Well if clarifies one thing at least, you can ignore Mike's st_Relate because 5 is not adjacent to a linear edge, it is only adjacent to a vertex, so st_touches should work fine. so you are looking for: 1. a specific triangle by id 2. that intersects triangle VC 3. and the triangles adjacent to triangle by id 4. and those that are contained in VC 5. sorted by distance to P1 limit 1 so something like: select id, the_geom from (select id, the_geom as adjacent from triangles where st_touches(the_geom, (select the_geom from triangles a, (select the_geom as vc from vc_table where id='p1') b where a.id=4)) c order by st_distance(c.the_geom, (select the_geom from points where id='p1')) asc limit 1; Untested, but should give you a model to work with. -Steve W On 10/29/2012 6:57 AM, Ed Linde wrote: Attached is a figure. Where the dotted line is the boundary of the voronoi cell whose generator is point P1. So triangle 4 intersects with the voronoi boundary, but we are interested in the adjacent triangles of triangle 4, which are closer to point P1. For example, triangle 5. Hope this helps. Cheers, Ed On Mon, Oct 29, 2012 at 11:50 AM, Nicolas Ribot nicolas.ri...@gmail.com mailto:nicolas.ri...@gmail.com wrote: Could you draw a figure ? Nicolas On 29 October 2012 11:03, Ed Linde edoli...@gmail.com mailto:edoli...@gmail.com wrote: Hi All, Thanks for the suggestions. For 1) I will look into how ST_touches works and see if it can pick up all the adjacent polygons to the one I have. And also look into Mike's suggestion on ST_relate...though I must admit it looks more complex. For 2) I will try to clarify it a bit more... its harder to do without a figure :) but here goes. Lets say we have a point Q which is the generator of a voronoi cell. Now I compute the intersection between the voronoi cell boundaries and my triangulation (Set of polygons) using ST_intersect. Once I have these triangles.. I say pick one triangle T that is intersecting the voronoi cell boundary of Q. For all the triangles adjacent to T, I need to know which triangles are INSIDE the voronoi boundary (closer to Q) and which adjacent triangles are just OUTSIDE the voronoi boundary (farther from Q). I am basically testing for a certain property by shrinking the voronoi cell (closer to Q) and another property when expanding the voronoi cell (away from Q). Just need to make this division of triangles. Haven't thought of a nice way to do this in postgis 2.0 So any suggestions would greatly help. Thanks, Ed On Mon, Oct 29, 2012 at 10:15 AM, Mike Toews mwto...@gmail.com mailto:mwto...@gmail.com wrote: On 29 October 2012 21:33, Ed Linde edoli...@gmail.com mailto:edoli...@gmail.com wrote: Hi All, I need help with 2 hard problems. I store triangles in a table as POLYGON. 1. I want to know for a given triangle, which triangles share an edge (adjacent) with this triangle. Sounds like you have a finite element mesh with nodes and elements. You can use ST_Relate with pattern 'FF2F11212' to pick out elements
Re: [postgis-users] Difficult Problem with Polygons
Hi, No. this is because some of your polygons are not valid: for instance: select st_isvalid('POLYGON ((593921 5219610 803,593921 5219610 818,593921 5219620 818,593921 5219620 803,593921 5219610 803))'::geometry); NOTICE: Too few points in geometry component at or near point 593921 5219610 803 st_isvalid f (1 row) you can control this with st_isvalid, st_isvalidReason and correct them with st_makeValid. Use only valid objects before processing them with Postgis functions. Nicolas On 29 October 2012 16:03, Ed Linde edoli...@gmail.com wrote: Thanks Nicolas. Just about the error, is this because the line segments are too close and postgis 2.0 could not handle this? If so is there a workaround, even if it means slightly having to perturb each point's position to not run into this bug. I was really hoping that the intersection of two polygonal shapes in 3D would be fairly simple in postgis 2.0 :( Ed On Mon, Oct 29, 2012 at 4:00 PM, Nicolas Ribot nicolas.ri...@gmail.com wrote: If the points are computed in the right order, you can store them and pass them to st_makeLine and st_makePolygon. If not, you can form a segment between 2 closest points and connect it to the closest points. On 29 October 2012 15:37, Ed Linde edoli...@gmail.com wrote: Hi All, Thanks for the tips! Just another thing, when I compute the transition points on each edge (shown as red points in my pdf). I need to join them to make a polygon. Wondering how I can connect them together so that I start with a point and end on it to form a closed polygon? Cheers, Ed On Mon, Oct 29, 2012 at 3:03 PM, Stephen Woodbridge wood...@swoodbridge.com wrote: Hi Ed, Well if clarifies one thing at least, you can ignore Mike's st_Relate because 5 is not adjacent to a linear edge, it is only adjacent to a vertex, so st_touches should work fine. so you are looking for: 1. a specific triangle by id 2. that intersects triangle VC 3. and the triangles adjacent to triangle by id 4. and those that are contained in VC 5. sorted by distance to P1 limit 1 so something like: select id, the_geom from (select id, the_geom as adjacent from triangles where st_touches(the_geom, (select the_geom from triangles a, (select the_geom as vc from vc_table where id='p1') b where a.id=4)) c order by st_distance(c.the_geom, (select the_geom from points where id='p1')) asc limit 1; Untested, but should give you a model to work with. -Steve W On 10/29/2012 6:57 AM, Ed Linde wrote: Attached is a figure. Where the dotted line is the boundary of the voronoi cell whose generator is point P1. So triangle 4 intersects with the voronoi boundary, but we are interested in the adjacent triangles of triangle 4, which are closer to point P1. For example, triangle 5. Hope this helps. Cheers, Ed On Mon, Oct 29, 2012 at 11:50 AM, Nicolas Ribot nicolas.ri...@gmail.com mailto:nicolas.ri...@gmail.com wrote: Could you draw a figure ? Nicolas On 29 October 2012 11:03, Ed Linde edoli...@gmail.com mailto:edoli...@gmail.com wrote: Hi All, Thanks for the suggestions. For 1) I will look into how ST_touches works and see if it can pick up all the adjacent polygons to the one I have. And also look into Mike's suggestion on ST_relate...though I must admit it looks more complex. For 2) I will try to clarify it a bit more... its harder to do without a figure :) but here goes. Lets say we have a point Q which is the generator of a voronoi cell. Now I compute the intersection between the voronoi cell boundaries and my triangulation (Set of polygons) using ST_intersect. Once I have these triangles.. I say pick one triangle T that is intersecting the voronoi cell boundary of Q. For all the triangles adjacent to T, I need to know which triangles are INSIDE the voronoi boundary (closer to Q) and which adjacent triangles are just OUTSIDE the voronoi boundary (farther from Q). I am basically testing for a certain property by shrinking the voronoi cell (closer to Q) and another property when expanding the voronoi cell (away from Q). Just need to make this division of triangles. Haven't thought of a nice way to do this in postgis 2.0 So any suggestions would greatly help. Thanks, Ed On Mon, Oct 29, 2012 at 10:15
Re: [postgis-users] Difficult Problem with Polygons
Thanks Nicolas! Will look at the script that generated the polygon text.. must have goofed something up there. On Mon, Oct 29, 2012 at 4:05 PM, Nicolas Ribot nicolas.ri...@gmail.comwrote: Hi, No. this is because some of your polygons are not valid: for instance: select st_isvalid('POLYGON ((593921 5219610 803,593921 5219610 818,593921 5219620 818,593921 5219620 803,593921 5219610 803))'::geometry); NOTICE: Too few points in geometry component at or near point 593921 5219610 803 st_isvalid f (1 row) you can control this with st_isvalid, st_isvalidReason and correct them with st_makeValid. Use only valid objects before processing them with Postgis functions. Nicolas On 29 October 2012 16:03, Ed Linde edoli...@gmail.com wrote: Thanks Nicolas. Just about the error, is this because the line segments are too close and postgis 2.0 could not handle this? If so is there a workaround, even if it means slightly having to perturb each point's position to not run into this bug. I was really hoping that the intersection of two polygonal shapes in 3D would be fairly simple in postgis 2.0 :( Ed On Mon, Oct 29, 2012 at 4:00 PM, Nicolas Ribot nicolas.ri...@gmail.com wrote: If the points are computed in the right order, you can store them and pass them to st_makeLine and st_makePolygon. If not, you can form a segment between 2 closest points and connect it to the closest points. On 29 October 2012 15:37, Ed Linde edoli...@gmail.com wrote: Hi All, Thanks for the tips! Just another thing, when I compute the transition points on each edge (shown as red points in my pdf). I need to join them to make a polygon. Wondering how I can connect them together so that I start with a point and end on it to form a closed polygon? Cheers, Ed On Mon, Oct 29, 2012 at 3:03 PM, Stephen Woodbridge wood...@swoodbridge.com wrote: Hi Ed, Well if clarifies one thing at least, you can ignore Mike's st_Relate because 5 is not adjacent to a linear edge, it is only adjacent to a vertex, so st_touches should work fine. so you are looking for: 1. a specific triangle by id 2. that intersects triangle VC 3. and the triangles adjacent to triangle by id 4. and those that are contained in VC 5. sorted by distance to P1 limit 1 so something like: select id, the_geom from (select id, the_geom as adjacent from triangles where st_touches(the_geom, (select the_geom from triangles a, (select the_geom as vc from vc_table where id='p1') b where a.id=4)) c order by st_distance(c.the_geom, (select the_geom from points where id='p1')) asc limit 1; Untested, but should give you a model to work with. -Steve W On 10/29/2012 6:57 AM, Ed Linde wrote: Attached is a figure. Where the dotted line is the boundary of the voronoi cell whose generator is point P1. So triangle 4 intersects with the voronoi boundary, but we are interested in the adjacent triangles of triangle 4, which are closer to point P1. For example, triangle 5. Hope this helps. Cheers, Ed On Mon, Oct 29, 2012 at 11:50 AM, Nicolas Ribot nicolas.ri...@gmail.com mailto:nicolas.ri...@gmail.com wrote: Could you draw a figure ? Nicolas On 29 October 2012 11:03, Ed Linde edoli...@gmail.com mailto:edoli...@gmail.com wrote: Hi All, Thanks for the suggestions. For 1) I will look into how ST_touches works and see if it can pick up all the adjacent polygons to the one I have. And also look into Mike's suggestion on ST_relate...though I must admit it looks more complex. For 2) I will try to clarify it a bit more... its harder to do without a figure :) but here goes. Lets say we have a point Q which is the generator of a voronoi cell. Now I compute the intersection between the voronoi cell boundaries and my triangulation (Set of polygons) using ST_intersect. Once I have these triangles.. I say pick one triangle T that is intersecting the voronoi cell boundary of Q. For all the triangles adjacent to T, I need to know which triangles are INSIDE the voronoi boundary (closer to Q) and which adjacent triangles are just OUTSIDE the voronoi boundary (farther from Q). I am basically testing for a certain property by shrinking the voronoi cell
Re: [postgis-users] Difficult Problem with Polygons
Yes, it looks like some points were not put in the right order before building a polygon, thus these butterfly polygons you generated. If the formed polygon are expected to be convex, you could use st_convexhull on the point cloud to generate the polygons. On 29 October 2012 16:09, Ed Linde edoli...@gmail.com wrote: Thanks Nicolas! Will look at the script that generated the polygon text.. must have goofed something up there. On Mon, Oct 29, 2012 at 4:05 PM, Nicolas Ribot nicolas.ri...@gmail.com wrote: Hi, No. this is because some of your polygons are not valid: for instance: select st_isvalid('POLYGON ((593921 5219610 803,593921 5219610 818,593921 5219620 818,593921 5219620 803,593921 5219610 803))'::geometry); NOTICE: Too few points in geometry component at or near point 593921 5219610 803 st_isvalid f (1 row) you can control this with st_isvalid, st_isvalidReason and correct them with st_makeValid. Use only valid objects before processing them with Postgis functions. Nicolas On 29 October 2012 16:03, Ed Linde edoli...@gmail.com wrote: Thanks Nicolas. Just about the error, is this because the line segments are too close and postgis 2.0 could not handle this? If so is there a workaround, even if it means slightly having to perturb each point's position to not run into this bug. I was really hoping that the intersection of two polygonal shapes in 3D would be fairly simple in postgis 2.0 :( Ed On Mon, Oct 29, 2012 at 4:00 PM, Nicolas Ribot nicolas.ri...@gmail.com wrote: If the points are computed in the right order, you can store them and pass them to st_makeLine and st_makePolygon. If not, you can form a segment between 2 closest points and connect it to the closest points. On 29 October 2012 15:37, Ed Linde edoli...@gmail.com wrote: Hi All, Thanks for the tips! Just another thing, when I compute the transition points on each edge (shown as red points in my pdf). I need to join them to make a polygon. Wondering how I can connect them together so that I start with a point and end on it to form a closed polygon? Cheers, Ed On Mon, Oct 29, 2012 at 3:03 PM, Stephen Woodbridge wood...@swoodbridge.com wrote: Hi Ed, Well if clarifies one thing at least, you can ignore Mike's st_Relate because 5 is not adjacent to a linear edge, it is only adjacent to a vertex, so st_touches should work fine. so you are looking for: 1. a specific triangle by id 2. that intersects triangle VC 3. and the triangles adjacent to triangle by id 4. and those that are contained in VC 5. sorted by distance to P1 limit 1 so something like: select id, the_geom from (select id, the_geom as adjacent from triangles where st_touches(the_geom, (select the_geom from triangles a, (select the_geom as vc from vc_table where id='p1') b where a.id=4)) c order by st_distance(c.the_geom, (select the_geom from points where id='p1')) asc limit 1; Untested, but should give you a model to work with. -Steve W On 10/29/2012 6:57 AM, Ed Linde wrote: Attached is a figure. Where the dotted line is the boundary of the voronoi cell whose generator is point P1. So triangle 4 intersects with the voronoi boundary, but we are interested in the adjacent triangles of triangle 4, which are closer to point P1. For example, triangle 5. Hope this helps. Cheers, Ed On Mon, Oct 29, 2012 at 11:50 AM, Nicolas Ribot nicolas.ri...@gmail.com mailto:nicolas.ri...@gmail.com wrote: Could you draw a figure ? Nicolas On 29 October 2012 11:03, Ed Linde edoli...@gmail.com mailto:edoli...@gmail.com wrote: Hi All, Thanks for the suggestions. For 1) I will look into how ST_touches works and see if it can pick up all the adjacent polygons to the one I have. And also look into Mike's suggestion on ST_relate...though I must admit it looks more complex. For 2) I will try to clarify it a bit more... its harder to do without a figure :) but here goes. Lets say we have a point Q which is the generator of a voronoi cell. Now I compute the intersection between the voronoi cell boundaries and my triangulation (Set of polygons) using ST_intersect. Once I have these triangles.. I say pick one triangle T that is intersecting the voronoi cell boundary of Q. For all the
Re: [postgis-users] Difficult Problem with Polygons
Ok thanks, will look into that function. Because I wonder if the s/w I am using is actually outputting the vertices of each face in a cyclical fashion or just arbitrarily. Cheers, Ed On Mon, Oct 29, 2012 at 4:23 PM, Nicolas Ribot nicolas.ri...@gmail.comwrote: Yes, it looks like some points were not put in the right order before building a polygon, thus these butterfly polygons you generated. If the formed polygon are expected to be convex, you could use st_convexhull on the point cloud to generate the polygons. On 29 October 2012 16:09, Ed Linde edoli...@gmail.com wrote: Thanks Nicolas! Will look at the script that generated the polygon text.. must have goofed something up there. On Mon, Oct 29, 2012 at 4:05 PM, Nicolas Ribot nicolas.ri...@gmail.com wrote: Hi, No. this is because some of your polygons are not valid: for instance: select st_isvalid('POLYGON ((593921 5219610 803,593921 5219610 818,593921 5219620 818,593921 5219620 803,593921 5219610 803))'::geometry); NOTICE: Too few points in geometry component at or near point 593921 5219610 803 st_isvalid f (1 row) you can control this with st_isvalid, st_isvalidReason and correct them with st_makeValid. Use only valid objects before processing them with Postgis functions. Nicolas On 29 October 2012 16:03, Ed Linde edoli...@gmail.com wrote: Thanks Nicolas. Just about the error, is this because the line segments are too close and postgis 2.0 could not handle this? If so is there a workaround, even if it means slightly having to perturb each point's position to not run into this bug. I was really hoping that the intersection of two polygonal shapes in 3D would be fairly simple in postgis 2.0 :( Ed On Mon, Oct 29, 2012 at 4:00 PM, Nicolas Ribot nicolas.ri...@gmail.com wrote: If the points are computed in the right order, you can store them and pass them to st_makeLine and st_makePolygon. If not, you can form a segment between 2 closest points and connect it to the closest points. On 29 October 2012 15:37, Ed Linde edoli...@gmail.com wrote: Hi All, Thanks for the tips! Just another thing, when I compute the transition points on each edge (shown as red points in my pdf). I need to join them to make a polygon. Wondering how I can connect them together so that I start with a point and end on it to form a closed polygon? Cheers, Ed On Mon, Oct 29, 2012 at 3:03 PM, Stephen Woodbridge wood...@swoodbridge.com wrote: Hi Ed, Well if clarifies one thing at least, you can ignore Mike's st_Relate because 5 is not adjacent to a linear edge, it is only adjacent to a vertex, so st_touches should work fine. so you are looking for: 1. a specific triangle by id 2. that intersects triangle VC 3. and the triangles adjacent to triangle by id 4. and those that are contained in VC 5. sorted by distance to P1 limit 1 so something like: select id, the_geom from (select id, the_geom as adjacent from triangles where st_touches(the_geom, (select the_geom from triangles a, (select the_geom as vc from vc_table where id='p1') b where a.id=4)) c order by st_distance(c.the_geom, (select the_geom from points where id='p1')) asc limit 1; Untested, but should give you a model to work with. -Steve W On 10/29/2012 6:57 AM, Ed Linde wrote: Attached is a figure. Where the dotted line is the boundary of the voronoi cell whose generator is point P1. So triangle 4 intersects with the voronoi boundary, but we are interested in the adjacent triangles of triangle 4, which are closer to point P1. For example, triangle 5. Hope this helps. Cheers, Ed On Mon, Oct 29, 2012 at 11:50 AM, Nicolas Ribot nicolas.ri...@gmail.com mailto:nicolas.ri...@gmail.com wrote: Could you draw a figure ? Nicolas On 29 October 2012 11:03, Ed Linde edoli...@gmail.com mailto:edoli...@gmail.com wrote: Hi All, Thanks for the suggestions. For 1) I will look into how ST_touches works and see if it can pick up all the adjacent polygons to the one I have. And also look into Mike's suggestion on ST_relate...though I must admit it looks more complex. For 2) I will try to clarify it a bit more... its harder to do without a figure :) but here
Re: [postgis-users] Difficult Problem with Polygons
Hi Nicolas, It seems like sometimes the points are one and the same and I get linestrings and not actual polygons. I pass these points in from a perl script, so is there a way I can just give the raw x,y,z coordinates of these points and do a st_convexhull function on them? Could you please give me a small example? I tried something like: The two coordinates marked in red and marked in orange are the same. bounds=# insert into vfaces values (1, bounds(# ST_GeomFromText('POLYGON((593901 5219610 814,593901 5219610 814,593899 5219610 814,593899 5219610 814,593901 5219610 814))') ); INSERT 0 1 bounds=# select st_isvalid(geomtext) from vfaces; NOTICE: Too few points in geometry component at or near point 593901 5219610 814 st_isvalid f (1 row) Thanks, Ed On Mon, Oct 29, 2012 at 4:26 PM, Ed Linde edoli...@gmail.com wrote: Ok thanks, will look into that function. Because I wonder if the s/w I am using is actually outputting the vertices of each face in a cyclical fashion or just arbitrarily. Cheers, Ed On Mon, Oct 29, 2012 at 4:23 PM, Nicolas Ribot nicolas.ri...@gmail.comwrote: Yes, it looks like some points were not put in the right order before building a polygon, thus these butterfly polygons you generated. If the formed polygon are expected to be convex, you could use st_convexhull on the point cloud to generate the polygons. On 29 October 2012 16:09, Ed Linde edoli...@gmail.com wrote: Thanks Nicolas! Will look at the script that generated the polygon text.. must have goofed something up there. On Mon, Oct 29, 2012 at 4:05 PM, Nicolas Ribot nicolas.ri...@gmail.com wrote: Hi, No. this is because some of your polygons are not valid: for instance: select st_isvalid('POLYGON ((593921 5219610 803,593921 5219610 818,593921 5219620 818,593921 5219620 803,593921 5219610 803))'::geometry); NOTICE: Too few points in geometry component at or near point 593921 5219610 803 st_isvalid f (1 row) you can control this with st_isvalid, st_isvalidReason and correct them with st_makeValid. Use only valid objects before processing them with Postgis functions. Nicolas On 29 October 2012 16:03, Ed Linde edoli...@gmail.com wrote: Thanks Nicolas. Just about the error, is this because the line segments are too close and postgis 2.0 could not handle this? If so is there a workaround, even if it means slightly having to perturb each point's position to not run into this bug. I was really hoping that the intersection of two polygonal shapes in 3D would be fairly simple in postgis 2.0 :( Ed On Mon, Oct 29, 2012 at 4:00 PM, Nicolas Ribot nicolas.ri...@gmail.com wrote: If the points are computed in the right order, you can store them and pass them to st_makeLine and st_makePolygon. If not, you can form a segment between 2 closest points and connect it to the closest points. On 29 October 2012 15:37, Ed Linde edoli...@gmail.com wrote: Hi All, Thanks for the tips! Just another thing, when I compute the transition points on each edge (shown as red points in my pdf). I need to join them to make a polygon. Wondering how I can connect them together so that I start with a point and end on it to form a closed polygon? Cheers, Ed On Mon, Oct 29, 2012 at 3:03 PM, Stephen Woodbridge wood...@swoodbridge.com wrote: Hi Ed, Well if clarifies one thing at least, you can ignore Mike's st_Relate because 5 is not adjacent to a linear edge, it is only adjacent to a vertex, so st_touches should work fine. so you are looking for: 1. a specific triangle by id 2. that intersects triangle VC 3. and the triangles adjacent to triangle by id 4. and those that are contained in VC 5. sorted by distance to P1 limit 1 so something like: select id, the_geom from (select id, the_geom as adjacent from triangles where st_touches(the_geom, (select the_geom from triangles a, (select the_geom as vc from vc_table where id='p1') b where a.id=4)) c order by st_distance(c.the_geom, (select the_geom from points where id='p1')) asc limit 1; Untested, but should give you a model to work with. -Steve W On 10/29/2012 6:57 AM, Ed Linde wrote: Attached is a figure. Where the dotted line is the boundary of the voronoi cell whose generator is point P1. So triangle 4 intersects with the voronoi boundary, but we are interested in the adjacent triangles of triangle 4, which
Re: [postgis-users] Difficult Problem with Polygons
You should filter out the consecutive points. If there are more than 2 points, you can then call st_convexHull() on the point set: with points as ( select 'POINT (0 0)'::geometry as geom UNION select 'POINT (1 0)'::geometry as geom UNION select 'POINT (1 1)'::geometry as geom ) select st_convexHull(st_collect(geom)) from points; If the points are aligned, convexHull will be a linestring, that you can discard or further process according to your needs. Nicolas On 29 October 2012 16:51, Ed Linde edoli...@gmail.com wrote: Hi Nicolas, It seems like sometimes the points are one and the same and I get linestrings and not actual polygons. I pass these points in from a perl script, so is there a way I can just give the raw x,y,z coordinates of these points and do a st_convexhull function on them? Could you please give me a small example? I tried something like: The two coordinates marked in red and marked in orange are the same. bounds=# insert into vfaces values (1, bounds(# ST_GeomFromText('POLYGON((593901 5219610 814,593901 5219610 814,593899 5219610 814,593899 5219610 814,593901 5219610 814))') ); INSERT 0 1 bounds=# select st_isvalid(geomtext) from vfaces; NOTICE: Too few points in geometry component at or near point 593901 5219610 814 st_isvalid f (1 row) Thanks, Ed On Mon, Oct 29, 2012 at 4:26 PM, Ed Linde edoli...@gmail.com wrote: Ok thanks, will look into that function. Because I wonder if the s/w I am using is actually outputting the vertices of each face in a cyclical fashion or just arbitrarily. Cheers, Ed On Mon, Oct 29, 2012 at 4:23 PM, Nicolas Ribot nicolas.ri...@gmail.com wrote: Yes, it looks like some points were not put in the right order before building a polygon, thus these butterfly polygons you generated. If the formed polygon are expected to be convex, you could use st_convexhull on the point cloud to generate the polygons. On 29 October 2012 16:09, Ed Linde edoli...@gmail.com wrote: Thanks Nicolas! Will look at the script that generated the polygon text.. must have goofed something up there. On Mon, Oct 29, 2012 at 4:05 PM, Nicolas Ribot nicolas.ri...@gmail.com wrote: Hi, No. this is because some of your polygons are not valid: for instance: select st_isvalid('POLYGON ((593921 5219610 803,593921 5219610 818,593921 5219620 818,593921 5219620 803,593921 5219610 803))'::geometry); NOTICE: Too few points in geometry component at or near point 593921 5219610 803 st_isvalid f (1 row) you can control this with st_isvalid, st_isvalidReason and correct them with st_makeValid. Use only valid objects before processing them with Postgis functions. Nicolas On 29 October 2012 16:03, Ed Linde edoli...@gmail.com wrote: Thanks Nicolas. Just about the error, is this because the line segments are too close and postgis 2.0 could not handle this? If so is there a workaround, even if it means slightly having to perturb each point's position to not run into this bug. I was really hoping that the intersection of two polygonal shapes in 3D would be fairly simple in postgis 2.0 :( Ed On Mon, Oct 29, 2012 at 4:00 PM, Nicolas Ribot nicolas.ri...@gmail.com wrote: If the points are computed in the right order, you can store them and pass them to st_makeLine and st_makePolygon. If not, you can form a segment between 2 closest points and connect it to the closest points. On 29 October 2012 15:37, Ed Linde edoli...@gmail.com wrote: Hi All, Thanks for the tips! Just another thing, when I compute the transition points on each edge (shown as red points in my pdf). I need to join them to make a polygon. Wondering how I can connect them together so that I start with a point and end on it to form a closed polygon? Cheers, Ed On Mon, Oct 29, 2012 at 3:03 PM, Stephen Woodbridge wood...@swoodbridge.com wrote: Hi Ed, Well if clarifies one thing at least, you can ignore Mike's st_Relate because 5 is not adjacent to a linear edge, it is only adjacent to a vertex, so st_touches should work fine. so you are looking for: 1. a specific triangle by id 2. that intersects triangle VC 3. and the triangles adjacent to triangle by id 4. and those that are contained in VC 5. sorted by distance to P1 limit 1 so something like: select id, the_geom from (select id, the_geom as adjacent from triangles where st_touches(the_geom, (select the_geom from triangles a, (select the_geom as vc from vc_table where id='p1')
Re: [postgis-users] Difficult Problem with Polygons
I tried something like the following without removing the same points ad it seems to work: SELECT st_astext(ST_ConvexHull(ST_GeomFromText('MULTIPOINT(593901 5219610 814,593901 5219610 814,593899 5219610 814,593899 5219610 814,593901 5219610 814)'))); LINESTRING Z (593901 5219610 814,593899 5219610 814) Ed On Mon, Oct 29, 2012 at 5:23 PM, Nicolas Ribot nicolas.ri...@gmail.comwrote: You should filter out the consecutive points. If there are more than 2 points, you can then call st_convexHull() on the point set: with points as ( select 'POINT (0 0)'::geometry as geom UNION select 'POINT (1 0)'::geometry as geom UNION select 'POINT (1 1)'::geometry as geom ) select st_convexHull(st_collect(geom)) from points; If the points are aligned, convexHull will be a linestring, that you can discard or further process according to your needs. Nicolas On 29 October 2012 16:51, Ed Linde edoli...@gmail.com wrote: Hi Nicolas, It seems like sometimes the points are one and the same and I get linestrings and not actual polygons. I pass these points in from a perl script, so is there a way I can just give the raw x,y,z coordinates of these points and do a st_convexhull function on them? Could you please give me a small example? I tried something like: The two coordinates marked in red and marked in orange are the same. bounds=# insert into vfaces values (1, bounds(# ST_GeomFromText('POLYGON((593901 5219610 814,593901 5219610 814,593899 5219610 814,593899 5219610 814,593901 5219610 814))') ); INSERT 0 1 bounds=# select st_isvalid(geomtext) from vfaces; NOTICE: Too few points in geometry component at or near point 593901 5219610 814 st_isvalid f (1 row) Thanks, Ed On Mon, Oct 29, 2012 at 4:26 PM, Ed Linde edoli...@gmail.com wrote: Ok thanks, will look into that function. Because I wonder if the s/w I am using is actually outputting the vertices of each face in a cyclical fashion or just arbitrarily. Cheers, Ed On Mon, Oct 29, 2012 at 4:23 PM, Nicolas Ribot nicolas.ri...@gmail.com wrote: Yes, it looks like some points were not put in the right order before building a polygon, thus these butterfly polygons you generated. If the formed polygon are expected to be convex, you could use st_convexhull on the point cloud to generate the polygons. On 29 October 2012 16:09, Ed Linde edoli...@gmail.com wrote: Thanks Nicolas! Will look at the script that generated the polygon text.. must have goofed something up there. On Mon, Oct 29, 2012 at 4:05 PM, Nicolas Ribot nicolas.ri...@gmail.com wrote: Hi, No. this is because some of your polygons are not valid: for instance: select st_isvalid('POLYGON ((593921 5219610 803,593921 5219610 818,593921 5219620 818,593921 5219620 803,593921 5219610 803))'::geometry); NOTICE: Too few points in geometry component at or near point 593921 5219610 803 st_isvalid f (1 row) you can control this with st_isvalid, st_isvalidReason and correct them with st_makeValid. Use only valid objects before processing them with Postgis functions. Nicolas On 29 October 2012 16:03, Ed Linde edoli...@gmail.com wrote: Thanks Nicolas. Just about the error, is this because the line segments are too close and postgis 2.0 could not handle this? If so is there a workaround, even if it means slightly having to perturb each point's position to not run into this bug. I was really hoping that the intersection of two polygonal shapes in 3D would be fairly simple in postgis 2.0 :( Ed On Mon, Oct 29, 2012 at 4:00 PM, Nicolas Ribot nicolas.ri...@gmail.com wrote: If the points are computed in the right order, you can store them and pass them to st_makeLine and st_makePolygon. If not, you can form a segment between 2 closest points and connect it to the closest points. On 29 October 2012 15:37, Ed Linde edoli...@gmail.com wrote: Hi All, Thanks for the tips! Just another thing, when I compute the transition points on each edge (shown as red points in my pdf). I need to join them to make a polygon. Wondering how I can connect them together so that I start with a point and end on it to form a closed polygon? Cheers, Ed On Mon, Oct 29, 2012 at 3:03 PM, Stephen Woodbridge wood...@swoodbridge.com wrote: Hi Ed, Well if clarifies one thing at least, you can ignore Mike's st_Relate because 5 is not adjacent to a linear edge, it is only adjacent to a vertex, so st_touches should work fine. so you are looking for: 1. a specific triangle by id 2. that intersects triangle VC 3. and the