Re: [postgis-users] Difficult Problem with Polygons

2012-10-29 Thread Francois Hugues
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

Re: [postgis-users] Difficult Problem with Polygons

2012-10-29 Thread Mike Toews
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

Re: [postgis-users] Difficult Problem with Polygons

2012-10-29 Thread Ed Linde
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

Re: [postgis-users] Difficult Problem with Polygons

2012-10-29 Thread Ed Linde
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.

Re: [postgis-users] Difficult Problem with Polygons

2012-10-29 Thread Nicolas Ribot
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

Re: [postgis-users] Difficult Problem with Polygons

2012-10-29 Thread Stephen Woodbridge
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

Re: [postgis-users] Difficult Problem with Polygons

2012-10-29 Thread Ed Linde
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

Re: [postgis-users] Difficult Problem with Polygons

2012-10-29 Thread Nicolas Ribot
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

Re: [postgis-users] Difficult Problem with Polygons

2012-10-29 Thread Ed Linde
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

Re: [postgis-users] Difficult Problem with Polygons

2012-10-29 Thread Nicolas Ribot
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

Re: [postgis-users] Difficult Problem with Polygons

2012-10-29 Thread Ed Linde
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

Re: [postgis-users] Difficult Problem with Polygons

2012-10-29 Thread Nicolas Ribot
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

Re: [postgis-users] Difficult Problem with Polygons

2012-10-29 Thread Ed Linde
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

Re: [postgis-users] Difficult Problem with Polygons

2012-10-29 Thread Ed Linde
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

Re: [postgis-users] Difficult Problem with Polygons

2012-10-29 Thread Nicolas Ribot
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

Re: [postgis-users] Difficult Problem with Polygons

2012-10-29 Thread Ed Linde
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