[prev in list] [next in list] [prev in thread] [next in thread]
List: postgis-users
Subject: Re: [postgis-users] Difficult Problem with Polygons
From: Ed Linde <edolinde () gmail ! com>
Date: 2012-10-29 16:34:50
Message-ID: CAK4dkcU0Brtd+L3=52p20zvbfCfN3KNyTOf6fNxK3dbs4U8_Ug () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
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.ribot@gmail.com>wrote:
> 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 <edolinde@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 <edolinde@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.ribot@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 <edolinde@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.ribot@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 <edolinde@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.ribot@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 <edolinde@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
> >>> >> >> > <woodbri@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.ribot@gmail.com
> >>> >> >> >>> <mailto:nicolas.ribot@gmail.com>> wrote:
> >>> >> >> >>>
> >>> >> >> >>> Could you draw a figure ?
> >>> >> >> >>>
> >>> >> >> >>> Nicolas
> >>> >> >> >>>
> >>> >> >> >>> On 29 October 2012 11:03, Ed Linde <edolinde@gmail.com
> >>> >> >> >>> <mailto:edolinde@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
> >>> >> >> >>> <mwtoews@gmail.com
> >>> >> >> >>> <mailto:mwtoews@gmail.com>> wrote:
> >>> >> >> >>> >>
> >>> >> >> >>> >> On 29 October 2012 21:33, Ed Linde <
> edolinde@gmail.com
> >>> >> >> >>> <mailto:edolinde@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
> >>> >> >> >>>
> 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
> >>> >> >
> >>> >> _______________________________________________
> >>> >> 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
>
[Attachment #5 (text/html)]
I tried something like the following without removing the same points ad it seems to \
work:<br><br>SELECT st_astext(ST_ConvexHull(ST_GeomFromText('MULTIPOINT(593901 \
5219610 814,593901 5219610 814,593899 5219610 814,593899 5219610 814,593901 5219610 \
814)'))); <br> "LINESTRING Z (593901 5219610 814,593899 5219610 \
814)"<br><br>Ed<br><br><div class="gmail_quote">On Mon, Oct 29, 2012 at 5:23 PM, \
Nicolas Ribot <span dir="ltr"><<a href="mailto:nicolas.ribot@gmail.com" \
target="_blank">nicolas.ribot@gmail.com</a>></span> wrote:<br> <blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">You should filter out the consecutive points. If there are \
more than 2<br> points, you can then call st_convexHull() on the point set:<br>
<br>
with points as (<br>
select 'POINT (0 0)'::geometry as geom<br>
UNION<br>
select 'POINT (1 0)'::geometry as geom<br>
UNION<br>
select 'POINT (1 1)'::geometry as geom<br>
) select st_convexHull(st_collect(geom))<br>
from points;<br>
<br>
If the points are aligned, convexHull will be a linestring, that you<br>
can discard or further process according to your needs.<br>
<span class="HOEnZb"><font color="#888888"><br>
Nicolas<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On 29 October 2012 16:51, Ed Linde <<a \
href="mailto:edolinde@gmail.com">edolinde@gmail.com</a>> wrote:<br> > Hi \
Nicolas,<br> > It seems like sometimes the points are one and the same and I \
get<br> > linestrings and not<br>
> actual polygons. I pass these points in from a perl script, so is there a<br>
> way I can just<br>
> give the raw x,y,z coordinates of these points and do a st_convexhull<br>
> function on them?<br>
> Could you please give me a small example?<br>
><br>
> I tried something like:<br>
> The two coordinates marked in red and marked in orange are the same.<br>
><br>
> bounds=# insert into vfaces values (1,<br>
> bounds(# ST_GeomFromText('POLYGON((593901 5219610 814,593901 5219610<br>
> 814,593899 5219610 814,593899 5219610 814,593901 5219610 814))') );<br>
> INSERT 0 1<br>
> bounds=# select st_isvalid(geomtext) from vfaces;<br>
> NOTICE: Too few points in geometry component at or near point 593901<br>
> 5219610 814<br>
><br>
> st_isvalid<br>
> ------------<br>
> f<br>
> (1 row)<br>
><br>
> Thanks,<br>
> Ed<br>
><br>
><br>
><br>
><br>
> On Mon, Oct 29, 2012 at 4:26 PM, Ed Linde <<a \
href="mailto:edolinde@gmail.com">edolinde@gmail.com</a>> wrote:<br> >><br>
>> Ok thanks, will look into that function. Because I wonder if the s/w I \
am<br> >> using is<br>
>> actually outputting the vertices of each face in a cyclical fashion or<br>
>> just<br>
>> arbitrarily.<br>
>><br>
>> Cheers,<br>
>> Ed<br>
>><br>
>><br>
>> On Mon, Oct 29, 2012 at 4:23 PM, Nicolas Ribot <<a \
href="mailto:nicolas.ribot@gmail.com">nicolas.ribot@gmail.com</a>><br> >> \
wrote:<br> >>><br>
>>> Yes, it looks like some points were not put in the right order \
before<br> >>> building a polygon, thus these "butterfly" polygons \
you generated.<br> >>> If the formed polygon are expected to be convex, you \
could use<br> >>> st_convexhull on the point cloud to generate the \
polygons.<br> >>><br>
>>> On 29 October 2012 16:09, Ed Linde <<a \
href="mailto:edolinde@gmail.com">edolinde@gmail.com</a>> wrote:<br> >>> \
> Thanks Nicolas! Will look at the script that generated the polygon<br> \
>>> > text..<br> >>> > must have goofed something up \
there.<br> >>> ><br>
>>> ><br>
>>> > On Mon, Oct 29, 2012 at 4:05 PM, Nicolas Ribot<br>
>>> > <<a \
href="mailto:nicolas.ribot@gmail.com">nicolas.ribot@gmail.com</a>><br> \
>>> > wrote:<br> >>> >><br>
>>> >> Hi,<br>
>>> >><br>
>>> >> No. this is because some of your polygons are not valid:<br>
>>> >> for instance:<br>
>>> >> select st_isvalid('POLYGON ((593921 5219610 803,593921 \
5219610<br> >>> >> 818,593921 5219620 818,593921 5219620 803,593921 \
5219610<br> >>> >> 803))'::geometry);<br>
>>> >> NOTICE: Too few points in geometry component at or near point \
593921<br> >>> >> 5219610 803<br>
>>> >> st_isvalid<br>
>>> >> ------------<br>
>>> >> f<br>
>>> >> (1 row)<br>
>>> >><br>
>>> >> you can control this with st_isvalid, st_isvalidReason and \
correct<br> >>> >> them with st_makeValid.<br>
>>> >><br>
>>> >> Use only valid objects before processing them with Postgis \
functions.<br> >>> >><br>
>>> >> Nicolas<br>
>>> >><br>
>>> >> On 29 October 2012 16:03, Ed Linde <<a \
href="mailto:edolinde@gmail.com">edolinde@gmail.com</a>> wrote:<br> >>> \
>> > Thanks Nicolas. Just about the error, is this because the line<br> \
>>> >> > segments<br> >>> >> > are<br>
>>> >> > too close<br>
>>> >> > and postgis 2.0 could not handle this? If so is there a \
workaround,<br> >>> >> > even<br>
>>> >> > if<br>
>>> >> > it means<br>
>>> >> > slightly having to "perturb" each point's \
position to not run into<br> >>> >> > this<br>
>>> >> > bug.<br>
>>> >> > I was really hoping that the intersection of two polygonal \
shapes in<br> >>> >> > 3D<br>
>>> >> > would be fairly<br>
>>> >> > simple in postgis 2.0 :(<br>
>>> >> ><br>
>>> >> > Ed<br>
>>> >> ><br>
>>> >> ><br>
>>> >> > On Mon, Oct 29, 2012 at 4:00 PM, Nicolas Ribot<br>
>>> >> > <<a \
href="mailto:nicolas.ribot@gmail.com">nicolas.ribot@gmail.com</a>><br> \
>>> >> > wrote:<br> >>> >> >><br>
>>> >> >> If the points are computed in the right order, you can \
store them<br> >>> >> >> and<br>
>>> >> >> pass them to st_makeLine and st_makePolygon.<br>
>>> >> >> If not, you can form a segment between 2 closest \
points and connect<br> >>> >> >> it<br>
>>> >> >> to the closest points.<br>
>>> >> >><br>
>>> >> >> On 29 October 2012 15:37, Ed Linde <<a \
href="mailto:edolinde@gmail.com">edolinde@gmail.com</a>> wrote:<br> >>> \
>> >> > Hi All,<br> >>> >> >> > Thanks for the \
tips! Just another thing, when I compute the<br> >>> >> >> > \
"transition<br> >>> >> >> > points" on each edge \
(shown as red points in my pdf).<br> >>> >> >> > I need to \
join them to make a polygon. Wondering how I can<br> >>> >> >> \
> connect<br> >>> >> >> > them<br>
>>> >> >> > together so that I start with a point and end on \
it<br> >>> >> >> > to form a closed polygon?<br>
>>> >> >> ><br>
>>> >> >> > Cheers,<br>
>>> >> >> > Ed<br>
>>> >> >> ><br>
>>> >> >> ><br>
>>> >> >> > On Mon, Oct 29, 2012 at 3:03 PM, Stephen \
Woodbridge<br> >>> >> >> > <<a \
href="mailto:woodbri@swoodbridge.com">woodbri@swoodbridge.com</a>> wrote:<br> \
>>> >> >> >><br> >>> >> >> >> \
Hi Ed,<br> >>> >> >> >><br>
>>> >> >> >> Well if clarifies one thing at least, you can \
ignore Mike's<br> >>> >> >> >> st_Relate<br>
>>> >> >> >> because 5 is not adjacent to a linear edge, \
it is only adjacent<br> >>> >> >> >> to a<br>
>>> >> >> >> vertex,<br>
>>> >> >> >> so st_touches should work fine.<br>
>>> >> >> >><br>
>>> >> >> >> so you are looking for:<br>
>>> >> >> >><br>
>>> >> >> >> 1. a specific triangle by id<br>
>>> >> >> >> 2. that intersects triangle VC<br>
>>> >> >> >> 3. and the triangles adjacent to triangle by \
id<br> >>> >> >> >> 4. and those that are contained in \
VC<br> >>> >> >> >> 5. sorted by distance to P1 limit \
1<br> >>> >> >> >><br>
>>> >> >> >> so something like:<br>
>>> >> >> >><br>
>>> >> >> >> select id, the_geom<br>
>>> >> >> >> from (select id, the_geom as adjacent<br>
>>> >> >> >> from triangles<br>
>>> >> >> >> where st_touches(the_geom,<br>
>>> >> >> >> (select \
the_geom<br> >>> >> >> >> \
from triangles a,<br> >>> >> >> >> \
(select the_geom as vc<br> >>> >> >> >> \
from vc_table<br> >>> >> >> >> \
where id='p1') b<br> >>> >> >> >> \
where <a href="http://a.id" target="_blank">a.id</a>=4)) c<br> >>> >> \
>> >> order by st_distance(c.the_geom, (select the_geom<br> >>> \
>> >> >> from points<br> \
>>> >> >> >> where \
id='p1')) asc limit 1;<br> >>> >> >> >><br>
>>> >> >> >> Untested, but should give you a model to work \
with.<br> >>> >> >> >><br>
>>> >> >> >> -Steve W<br>
>>> >> >> >><br>
>>> >> >> >><br>
>>> >> >> >><br>
>>> >> >> >> On 10/29/2012 6:57 AM, Ed Linde wrote:<br>
>>> >> >> >>><br>
>>> >> >> >>> Attached is a figure. Where the dotted \
line is the boundary of<br> >>> >> >> >>> the<br>
>>> >> >> >>> voronoi cell whose<br>
>>> >> >> >>> generator is point P1. So triangle \
"4" intersects with the<br> >>> >> >> >>> \
voronoi<br> >>> >> >> >>> boundary, but we are<br>
>>> >> >> >>> interested in the adjacent triangles of \
triangle 4, which are<br> >>> >> >> >>> closer<br>
>>> >> >> >>> to<br>
>>> >> >> >>> point P1.<br>
>>> >> >> >>> For example, triangle 5.<br>
>>> >> >> >>><br>
>>> >> >> >>> Hope this helps.<br>
>>> >> >> >>> Cheers,<br>
>>> >> >> >>> Ed<br>
>>> >> >> >>><br>
>>> >> >> >>> On Mon, Oct 29, 2012 at 11:50 AM, Nicolas \
Ribot<br> >>> >> >> >>> <<a \
href="mailto:nicolas.ribot@gmail.com">nicolas.ribot@gmail.com</a><br> >>> \
>> >> >>> <mailto:<a \
href="mailto:nicolas.ribot@gmail.com">nicolas.ribot@gmail.com</a>>> wrote:<br> \
>>> >> >> >>><br> >>> >> >> \
>>> Could you draw a figure ?<br> >>> >> >> \
>>><br> >>> >> >> >>> Nicolas<br>
>>> >> >> >>><br>
>>> >> >> >>> On 29 October 2012 11:03, Ed Linde \
<<a href="mailto:edolinde@gmail.com">edolinde@gmail.com</a><br> >>> \
>> >> >>> <mailto:<a \
href="mailto:edolinde@gmail.com">edolinde@gmail.com</a>>> wrote:<br> \
>>> >> >> >>> > Hi All,<br> >>> \
>> >> >>> > Thanks for the suggestions.<br> >>> \
>> >> >>> > For 1) I will look into how ST_touches works \
and see if<br> >>> >> >> >>> it<br>
>>> >> >> >>> can<br>
>>> >> >> >>> pick up all<br>
>>> >> >> >>> > the adjacent polygons to<br>
>>> >> >> >>> > the one I have. And also look \
into Mike's suggestion on<br> >>> >> >> >>> \
ST_relate...though I<br> >>> >> >> >>> > must \
admit it looks<br> >>> >> >> >>> > more \
complex.<br> >>> >> >> >>> > For 2) I will try \
to clarify it a bit more... its harder<br> >>> >> >> \
>>> to<br> >>> >> >> >>> do<br>
>>> >> >> >>> without a<br>
>>> >> >> >>> > figure :) but here goes.<br>
>>> >> >> >>> ><br>
>>> >> >> >>> > Lets say we have a point Q \
which is the generator of a<br> >>> >> >> >>> \
voronoi<br> >>> >> >> >>> cell. Now I<br>
>>> >> >> >>> > compute the<br>
>>> >> >> >>> > intersection between the \
voronoi cell boundaries and my<br> >>> >> >> >>> \
triangulation (Set<br> >>> >> >> >>> > of \
polygons)<br> >>> >> >> >>> > using \
ST_intersect. Once I have these triangles.. I say<br> >>> >> >> \
>>> pick<br> >>> >> >> >>> one<br>
>>> >> >> >>> triangle T<br>
>>> >> >> >>> > that is<br>
>>> >> >> >>> > intersecting the voronoi cell \
boundary of Q.<br> >>> >> >> >>> > For all the \
triangles adjacent to T, I need to know<br> >>> >> >> \
>>> which<br> >>> >> >> >>> triangles \
are<br> >>> >> >> >>> > INSIDE the voronoi<br>
>>> >> >> >>> > boundary (closer to Q) and \
which adjacent triangles are<br> >>> >> >> >>> just<br>
>>> >> >> >>> OUTSIDE the<br>
>>> >> >> >>> > voronoi<br>
>>> >> >> >>> > boundary (farther from Q). I am \
basically testing for a<br> >>> >> >> >>> certain<br>
>>> >> >> >>> property by<br>
>>> >> >> >>> > "shrinking" the<br>
>>> >> >> >>> > voronoi cell (closer to Q) and \
another property when<br> >>> >> >> >>> \
"expanding"<br> >>> >> >> >>> the \
voronoi<br> >>> >> >> >>> > cell (away from \
Q).<br> >>> >> >> >>> > Just need to make this \
division of triangles. Haven't<br> >>> >> >> >>> \
thought<br> >>> >> >> >>> of<br>
>>> >> >> >>> a nice way<br>
>>> >> >> >>> > to do this in postgis 2.0<br>
>>> >> >> >>> > So any suggestions would \
greatly help.<br> >>> >> >> >>> ><br>
>>> >> >> >>> > Thanks,<br>
>>> >> >> >>> > Ed<br>
>>> >> >> >>> ><br>
>>> >> >> >>> > On Mon, Oct 29, 2012 at 10:15 \
AM, Mike Toews<br> >>> >> >> >>> <<a \
href="mailto:mwtoews@gmail.com">mwtoews@gmail.com</a><br> >>> >> \
>> >>> <mailto:<a \
href="mailto:mwtoews@gmail.com">mwtoews@gmail.com</a>>> wrote:<br> >>> \
>> >> >>> >><br> >>> >> >> \
>>> >> On 29 October 2012 21:33, Ed Linde <<a \
href="mailto:edolinde@gmail.com">edolinde@gmail.com</a><br> >>> >> \
>> >>> <mailto:<a \
href="mailto:edolinde@gmail.com">edolinde@gmail.com</a>>> wrote:<br> \
>>> >> >> >>> >> > Hi All,<br> \
>>> >> >> >>> >> > I need help with 2 \
hard problems. I store triangles<br> >>> >> >> >>> in \
a<br> >>> >> >> >>> table<br>
>>> >> >> >>> as<br>
>>> >> >> >>> >> > POLYGON.<br>
>>> >> >> >>> >> ><br>
>>> >> >> >>> >> > 1. I want to know for \
a given triangle, which<br> >>> >> >> >>> triangles<br>
>>> >> >> >>> share<br>
>>> >> >> >>> an edge<br>
>>> >> >> >>> >> > (adjacent) with this \
triangle.<br> >>> >> >> >>> >><br>
>>> >> >> >>> >> Sounds like you have a \
finite element mesh with nodes<br> >>> >> >> >>> \
and<br> >>> >> >> >>> elements.<br>
>>> >> >> >>> >> You can use ST_Relate with \
pattern 'FF2F11212' to pick<br> >>> >> >> >>> \
out<br> >>> >> >> >>> elements<br>
>>> >> >> >>> >> that share the same edge. \
This DE-9-IM is sort-of a<br> >>> >> >> >>> custom<br>
>>> >> >> >>> ST_Touches,<br>
>>> >> >> >>> >> but only takes linear \
boundary overlaps. So if you have<br> >>> >> >> >>> \
a<br> >>> >> >> >>> table<br>
>>> >> >> >>> >> "elements", and \
you want to find ones that touch ID<br> >>> >> >> >>> \
567:<br> >>> >> >> >>> >><br>
>>> >> >> >>> >> SELECT elements.*<br>
>>> >> >> >>> >> FROM elements, elements as \
e<br> >>> >> >> >>> >> WHERE <a \
href="http://e.id" target="_blank">e.id</a> <<a href="http://e.id" \
target="_blank">http://e.id</a>> = 567 AND<br> >>> >> >> \
>>><br> >>> >> >> >>> >> \
ST_Relate(elements.geom, e.geom, 'FF2F11212');<br> >>> >> \
>> >>> >><br> >>> >> >> >>> \
>> I'm not certain about your second question.<br> >>> >> \
>> >>> >><br> >>> >> >> >>> \
>> -Mike<br> >>> >> >> >>> >> \
_______________________________________________<br> >>> >> >> \
>>> >> postgis-users mailing list<br> >>> >> \
>> >>> >> <a \
href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
>>> >> >> >>> <mailto:<a \
href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a>><br>
>>> >> >> >>><br>
>>> >> >> >>> >><br>
>>> >> >> >>> <a \
href="http://postgis.refractions.net/mailman/listinfo/postgis-users" \
target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br> \
>>> >> >> >>> ><br> >>> >> \
>> >>> ><br> >>> >> >> >>> \
><br> >>> >> >> >>> > \
_______________________________________________<br> >>> >> >> \
>>> > postgis-users mailing list<br> >>> >> >> \
>>> > <a \
href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
>>> >> >> >>> <mailto:<a \
href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a>><br>
>>> >> >> >>><br>
>>> >> >> >>> ><br>
>>> >> >> >>> <a \
href="http://postgis.refractions.net/mailman/listinfo/postgis-users" \
target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br> \
>>> >> >> >>> ><br> >>> >> \
>> >>> _______________________________________________<br> \
>>> >> >> >>> postgis-users mailing list<br> \
>>> >> >> >>> <a \
href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
>>> >> >> >>> <mailto:<a \
href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a>><br>
>>> >> >> >>><br>
>>> >> >> >>><br>
>>> >> >> >>> <a \
href="http://postgis.refractions.net/mailman/listinfo/postgis-users" \
target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br> \
>>> >> >> >>><br> >>> >> >> \
>>><br> >>> >> >> >>><br>
>>> >> >> >>><br>
>>> >> >> >>> \
_______________________________________________<br> >>> >> >> \
>>> postgis-users mailing list<br> >>> >> >> \
>>> <a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
>>> >> >> >>> <a \
href="http://postgis.refractions.net/mailman/listinfo/postgis-users" \
target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br> \
>>> >> >> >>><br> >>> >> >> \
>><br> >>> >> >> >> \
_______________________________________________<br> >>> >> >> \
>> postgis-users mailing list<br> >>> >> >> >> <a \
href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
>>> >> >> >> <a \
href="http://postgis.refractions.net/mailman/listinfo/postgis-users" \
target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br> \
>>> >> >> ><br> >>> >> >> ><br>
>>> >> >> ><br>
>>> >> >> > \
_______________________________________________<br> >>> >> >> \
> postgis-users mailing list<br> >>> >> >> > <a \
href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
>>> >> >> > <a \
href="http://postgis.refractions.net/mailman/listinfo/postgis-users" \
target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br> \
>>> >> >> ><br> >>> >> >> \
_______________________________________________<br> >>> >> >> \
postgis-users mailing list<br> >>> >> >> <a \
href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
>>> >> >> <a \
href="http://postgis.refractions.net/mailman/listinfo/postgis-users" \
target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br> \
>>> >> ><br> >>> >> ><br>
>>> >> ><br>
>>> >> > _______________________________________________<br>
>>> >> > postgis-users mailing list<br>
>>> >> > <a \
href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
>>> >> > <a \
href="http://postgis.refractions.net/mailman/listinfo/postgis-users" \
target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br> \
>>> >> ><br> >>> >> \
_______________________________________________<br> >>> >> \
postgis-users mailing list<br> >>> >> <a \
href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
>>> >> <a \
href="http://postgis.refractions.net/mailman/listinfo/postgis-users" \
target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br> \
>>> ><br> >>> ><br>
>>> ><br>
>>> > _______________________________________________<br>
>>> > postgis-users mailing list<br>
>>> > <a \
href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
>>> > <a \
href="http://postgis.refractions.net/mailman/listinfo/postgis-users" \
target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br> \
>>> ><br> >>> \
_______________________________________________<br> >>> postgis-users \
mailing list<br> >>> <a \
href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
>>> <a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" \
target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br> \
>><br> >><br>
><br>
><br>
> _______________________________________________<br>
> postgis-users mailing list<br>
> <a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
> <a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" \
target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br> \
><br> _______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
<a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" \
target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br> \
</div></div></blockquote></div><br>
_______________________________________________
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic