<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7651.59">
<TITLE>[postgis-users] RE: RE: RE: Select Point or PolyGon Polyline in Box</TITLE>
</HEAD>
<BODY>
<DIV id=idOWAReplyText88816 dir=ltr>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2>Anhtin,</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2>Sorry I misunderstood what you were trying
to do. I guess your mainroads are just regular old lines and not boundary
lines of polygons. The buildarea is meant to take a closed line and
convert to a polygon. If its not closed I think it just returns
null.</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2> I think what you want then if you are
trying to find what road a point sits on is </FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT><FONT face=Arial size=2></FONT><FONT
face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT size=2>SELECT * FROM mainroad WHERE
GeomFromText('POINT(517651 2121421)', 42102)
&&<BR>the_geom <BR> AND
distance(the_geom,<BR>GeomFromText('POINT(517651 2121421)', 42102)) =
0</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2> - and for that you don't need build
area</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2>If you are dealing with centerlines - you
may however need to expand your line out a bit and check if a point sits within
x distance of a line if your points aren't exactly aligned on road
centerlines. Something like</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT size=2>SELECT * FROM mainroad WHERE
expand(GeomFromText('POINT(517651 2121421)', 42102),1)
&&<BR>the_geom<BR> AND
distance(the_geom,<BR>GeomFromText('POINT(517651 2121421)', 42102)) <=
1</FONT></DIV>
<DIV dir=ltr><FONT size=2></FONT> </DIV>
<DIV dir=ltr><FONT size=2>where 1 you can replace with whatever you think is a
good measure for a width of a road.</FONT></DIV>
<DIV dir=ltr><FONT size=2></FONT> </DIV>
<DIV dir=ltr><FONT size=2>Hope that helps,</FONT></DIV>
<DIV dir=ltr><FONT size=2>Regina</FONT></DIV></DIV>
<DIV dir=ltr><BR>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B>
postgis-users-bounces@postgis.refractions.net on behalf of
anhtin<BR><B>Sent:</B> Thu 4/12/2007 10:39 PM<BR><B>To:</B>
postgis-users@postgis.refractions.net<BR><B>Subject:</B> [postgis-users] RE: RE:
RE: Select Point or PolyGon Polyline in Box<BR></FONT><BR></DIV>
<DIV><BR>
<P><FONT size=2>thanks very much all support to me :)<BR>i still understand in
Select point with PolyLine with command :<BR>when i run<BR>SELECT * FROM
mainroad WHERE GeomFromText('POINT(517651 2121421)', 42102)
&&<BR>the_geom<BR>Have some result<BR><BR>if have assgin to add the
command:<BR><BR> AND
distance(BuildArea(the_geom),<BR>GeomFromText('POINT(517651 2121421)', 42102)) =
0<BR><BR>but it no result ????? i dont understand this
command<BR><BR><BR><BR><BR>Obe, Regina DND\MIS
wrote:<BR>><BR>> To find the polygon where a point resides - there are
actually several<BR>> ways of doing this and I'm not sure which one is
fastest or the<BR>> preferred. There is (in these I am assuming the_poly is
the polygon<BR>> geometry)<BR>><BR>> I usually just do the first
because it is pretty all purpose for most of<BR>> the things I do and you
don't have to think about the order of arguments<BR>> in distance like you
have to in within)<BR>><BR>> SELECT *<BR>> FROM polygon WHERE
GeomFromText('POINT(295149 2315499)', -1) && the_poly<BR>> AND
distance(the_poly, GeomFromText('POINT(295149 2315499)', -1)) =
0<BR>><BR>> There is also<BR>><BR>> SELECT *<BR>> FROM polygon
WHERE GeomFromText('POINT(295149 2315499)', -1) && the_poly<BR>> AND
Within(GeomFromText('POINT(295149 2315499)',
-1),the_poly)<BR>><BR>><BR>> For Poly Line's it's a little trickier
because there is no such thing in<BR>> postgis lingo for Polyline. I
think the closest is Linestring or<BR>> MultiLineString. So if you have a
linestring or multilinestring that<BR>> forms a polyline, I'm not sure if you
would have to convert it to a<BR>> polygon using buildarea to get what you
want or if you can get away with<BR>> some other relational operator to do it
without conversion. NOTE: I<BR>> have never tried this before -
this is simply a guess on my part<BR>><BR>> the_polyline is a linestring
or multilinestring.<BR>><BR>><BR>> SELECT *<BR>> FROM polylines
WHERE GeomFromText('POINT(295149 2315499)', -1) &&<BR>> the_polyline
AND distance(BuildArea(the_polyline),<BR>> GeomFromText('POINT(295149
2315499)', -1)) = 0<BR>><BR>> OR<BR>><BR>> SELECT *<BR>> FROM
polylines WHERE GeomFromText('POINT(295149 2315499)', -1) &&<BR>>
the_polyline AND Within(GeomFromText('POINT(295149 2315499)',<BR>>
-1),BuildArea(the_polyline))<BR>><BR>><BR>><BR>><BR>><BR>><BR>>
-----Original Message-----<BR>> From:
postgis-users-bounces@postgis.refractions.net<BR>> [<A
href="mailto:postgis-users-bounces@postgis.refractions.net">mailto:postgis-users-bounces@postgis.refractions.net</A>]
On Behalf Of<BR>> anhtin<BR>> Sent: Wednesday, April 11, 2007 11:40
PM<BR>> To: postgis-users@postgis.refractions.net<BR>> Subject:
[postgis-users] RE: RE: Select Point or PolyGon Polyline in
Box<BR>><BR>><BR>> Thanks very much so support for
me<BR>><BR>> if i have that point i want select this point be in
Polygon<BR>> ex: i have table Polygon is province. i want select
point(295054<BR>> 849444) be<BR>> in Polygon ????<BR>> and or be
in polyline<BR>> can u show 2 way with polygon and polyline<BR>> thanks
befor :)<BR>><BR>><BR>><BR>> Obe, Regina
DND\MIS wrote:<BR>>><BR>>> Don't quite get what you are
asking? Are you trying to compare if 2<BR>>> points are the same or
if a point is within x distance of another<BR>> point?<BR>>> or
something entirely different?<BR>>><BR>>> If you wanted to select
all points within x distance of your reference<BR>>> point , then it would
be (again replace -1 with the correct SRID and<BR>>> distance is always
measured in the units of your spatial reference<BR>>>
system)<BR>>><BR>>> SELECT *<BR>>> FROM pointdemo<BR>>>
WHERE the_point && Expand(GeomFromText('POINT(295149 2315499)',
-1),<BR>> 10)<BR>>> AND<BR>>>
distance(the_point,GeomFromText('POINT(295149 2315499)', -1)) <=<BR>>>
10<BR>>><BR>>> If you wanted to know if 2 points are the same then
it would be<BR>>> SELECT *<BR>>> FROM pointdemo<BR>>> WHERE
the_point ~= GeomFromText('POINT(295149 2315499)',
-1)<BR>>> <BR>>><BR>>> <BR>>><BR>>>
-----Original Message-----<BR>>> From:
postgis-users-bounces@postgis.refractions.net<BR>>> [<A
href="mailto:postgis-users-bounces@postgis.refractions.net">mailto:postgis-users-bounces@postgis.refractions.net</A>]
On Behalf Of<BR>>> anhtin<BR>>> Sent: Wednesday, April 11, 2007
12:32 AM<BR>>> To: postgis-users@postgis.refractions.net<BR>>>
Subject: [postgis-users] RE: Select Point or PolyGon Polyline in
Box<BR>>><BR>>><BR>>> thanks<BR>>> How is Select if it
is Point ?????<BR>>><BR>>><BR>>><BR>>> Obe,
Regina DND\MIS wrote:<BR>>>><BR>>>>
Assuming your box is in the same srid as your points. It would
be<BR>>>> something like<BR>>>><BR>>>> SELECT
*<BR>>>> FROM pointdemo<BR>>>> WHERE the_point
&& setsrid('BOX(295149 2315499, 465992<BR>>>> 2163790)'::box2d,
-1)<BR>>>><BR>>>><BR>>>> Note - above I am assuming
your point geometry is called the_point<BR>> and<BR>>>> your SRID is
-1<BR>>>> If the srid of your point geometry is not -1 then
change -1 to what<BR>>> it<BR>>>> should
be.<BR>>>><BR>>>><BR>>>> -----Original
Message-----<BR>>>> From:
postgis-users-bounces@postgis.refractions.net<BR>>>> [<A
href="mailto:postgis-users-bounces@postgis.refractions.net">mailto:postgis-users-bounces@postgis.refractions.net</A>]
On Behalf Of<BR>>>> anhtin<BR>>>> Sent: Tuesday, April 10,
2007 6:18 AM<BR>>>> To:
postgis-users@postgis.refractions.net<BR>>>> Subject: [postgis-users]
Select Point or PolyGon Polyline in
Box<BR>>>><BR>>>><BR>>>> hi all<BR>>>> i
have question to postgis<BR>>>> i have table Pointdemo<BR>>>>
I want select all point in my Box("Rectangle") on PostGis<BR>>>> my box
is corrdinate<BR>>>> ex: full extend is:Box(110638 2587481, 903350
1972446) ---> xmin<BR>> ymin,<BR>>>> xmax<BR>>>>
ymax<BR>>>> i want select point in Box(295149 2315499, 465992
2163790) ---> xmin<BR>>>> ymin,<BR>>>> xmax
ymax<BR>>>> How will i do that
?????<BR>>>><BR>>>><BR>>>> --<BR>>>> View
this message in context:<BR>>>><BR>>><BR>> <A
href="http://www.nabble.com/Select-Point-or-PolyGon-Polyline-in-Box-tf3552167">http://www.nabble.com/Select-Point-or-PolyGon-Polyline-in-Box-tf3552167</A>.<BR>>>>
html#a9916986<BR>>>> Sent from the PostGIS - User mailing list archive
at Nabble.com.<BR>>>><BR>>>>
_______________________________________________<BR>>>> postgis-users
mailing list<BR>>>>
postgis-users@postgis.refractions.net<BR>>>> <A
href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR>>>><BR>>>>
-----------------------------------------<BR>>>> The substance of this
message, including any attachments, may be<BR>>>> confidential, legally
privileged and/or exempt from disclosure<BR>>>> pursuant to
Massachusetts law. It is intended<BR>>>> solely for the addressee. If
you received this in error, please<BR>>>> contact the sender and delete
the material from any computer.<BR>>>><BR>>>>
_______________________________________________<BR>>>> postgis-users
mailing list<BR>>>>
postgis-users@postgis.refractions.net<BR>>>> <A
href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR>>>><BR>>>><BR>>><BR>>>
--<BR>>> View this message in context:<BR>>><BR>> <A
href="http://www.nabble.com/Select-Point-or-PolyGon-Polyline-in-Box-tf3552167">http://www.nabble.com/Select-Point-or-PolyGon-Polyline-in-Box-tf3552167</A>.<BR>>>
html#a9933066<BR>>> Sent from the PostGIS - User mailing list archive at
Nabble.com.<BR>>><BR>>>
_______________________________________________<BR>>> postgis-users
mailing list<BR>>> postgis-users@postgis.refractions.net<BR>>> <A
href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR>>>
_______________________________________________<BR>>> postgis-users
mailing list<BR>>> postgis-users@postgis.refractions.net<BR>>> <A
href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR>>><BR>>><BR>><BR>>
--<BR>> View this message in context:<BR>> <A
href="http://www.nabble.com/Select-Point-or-PolyGon-Polyline-in-Box-tf3552167">http://www.nabble.com/Select-Point-or-PolyGon-Polyline-in-Box-tf3552167</A>.<BR>>
html#a9952489<BR>> Sent from the PostGIS - User mailing list archive at
Nabble.com.<BR>><BR>>
_______________________________________________<BR>> postgis-users mailing
list<BR>> postgis-users@postgis.refractions.net<BR>> <A
href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR>>
_______________________________________________<BR>> postgis-users mailing
list<BR>> postgis-users@postgis.refractions.net<BR>> <A
href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR>><BR>><BR><BR>--<BR>View
this message in context: <A
href="http://www.nabble.com/Select-Point-or-PolyGon-Polyline-in-Box-tf3552167.html#a9972005">http://www.nabble.com/Select-Point-or-PolyGon-Polyline-in-Box-tf3552167.html#a9972005</A><BR>Sent
from the PostGIS - User mailing list archive at
Nabble.com.<BR><BR>_______________________________________________<BR>postgis-users
mailing list<BR>postgis-users@postgis.refractions.net<BR><A
href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR></FONT></P></DIV>
</BODY>
</HTML>