<html>
<head>
</head>
<body>You should look at the function st_DWithin. <br />
<br />
But I think you have some decisions to make. What output do you want. Do you want both the points that isn't exactly at the same place or just one of them.<br />
Do you want the result as multipoint or points (I didn't get the problem with one point per row. Is the problem to put them into the rows, then postgis makes that very good with st_dump, or is the problem, handling them afterwards)<br />
<br />
<br />
select ?? what do you want to get ???<br />
from<br />
(select (st_dump(geom)).geom from test1) a,<br />
(select (st_dump(geom)).geom from test2) b<br />
where st_dwithin(a.geom,b.geom,1)<br />
<br />
you can rebuild those parts of the multipoints that meets your demand of being in a range. Then you should keep som id from the original multipoints and use st_collect and group the data with that id. If you want your multipoints from test1 like that it should work with:<br />
<br />
select gid, st_collect(a.geom) from <br />
(select gid, (st_dump(geom)).geom from test1) a,<br />
test2<br />
where st_dwithin(a.geom,test2.geom,1)<br />
group by gid;<br />
<br />
note that you don't have to do st_dump on test2 in this case because we can check for the distance to the whole multipoint.<br />
<br />
hope I understood you right.<br />
<br />
By the way, the postgis-users list is better for this type of questions.<br />
<br />
Hope that helps<br />
Nicklas<br />
<br />
2009-07-19 kevinridge wrote:<br />
<br />
<br />
>Hello,<br />
>I have two multipoint fields (lets call them test1 and test2). I am<br />
>wondering how to compute an intersection between them but taking a range in<br />
>the middle.<br />
><br />
>For example, lets say test1 holds ('0 0, 1 0, 0 1, 1 1') and test2 holds ('0<br />
>0, 5 5')<br />
><br />
>Now when i do select intersection(test2.geom, test1.geom) it would give me<br />
>('0 0'). Is there a way i can specify the distance apart also for each<br />
>point? <br />
><br />
>So something like select intersection(test2.geom, test1.geom, 1) and it<br />
>would take each point in test1, extend its geometry by 1 and see if it<br />
>matches anything in test2. So it would return ('0 0, 1 0, 0 1')<br />
><br />
>I am basically trying to find everything that is similar in two multipoints<br />
>but at a distance apart (so its not right on top of each other). I tried<br />
>doing this with point but since point means i have to insert a row for each<br />
>new one, its really slow when adding like 5 million points. <br />
><br />
>Is there a better way than what i am doing? I am really new to postgis and<br />
>any help would be GREATLY appreciated :)<br />
>-- <br />
>View this message in context: http://www.nabble.com/Two-Multipoint-and-Range-Intersection-tp24558603p24558603.html<br />
>Sent from the PostGIS - Dev mailing list archive at Nabble.com.<br />
><br />
>_______________________________________________<br />
>postgis-devel mailing list<br />
>postgis-devel@postgis.refractions.net<br />
>http://postgis.refractions.net/mailman/listinfo/postgis-devel<br />
><br />
>
</body>
</html>