<html>
<head>
</head>
<body>Hallo<br />
<br />
>From Esri perspective I don't think you should consider it basic functionality
since it requires ArcInfo license. <br />
<br />
But I agree that the functionality included in this Near function is
quite basic. But there is a lot of different functionality mixed up in
the function.<br />
<br />
If you are storing your data in PostGIS you can do it there. If you
don't... it might be a great idea to do :-)<br />
<br />
To get the search radius you use ST_Dwithin. Then you can order the
catched features with ST_Distance and from your resulting nearest
features you can get all the resulting data that is included in this
Near function by using different of functions<br />
<br />
Here comes an example where I have tried to do it as similar as the near
function as possible.<br />
You can run it here:<br />
http://www.postgisonline.org/map.php<br />
The query searches for the houses closest to the three phone_masts. To
easier see what it is about you can choose "All_simple_maps" under
background maps.<br />
The resulting map will just show a line between the phone mast and the
closest house and then you can find the attribute data if you press
"Attribute table Map1"<br />
<br />
This near_x and near_y I don't really understand. On the pictures it
looks like they are dealing with delta x and delta y but in the text
they are just discussing the x and y value of the found closest point.
Both variants is easy to do but here I calculate the delta x and delta
y.<br />
<br />
The query looks more messy than nessecary because I have squized in all
that is included in near function. In reality you just specify the parts
you need of course. <br />
<br />
Here it comes, just copy it into the big textarea and press "Map 1" and
choose background map as desribed above<br />
<br />
<br />
SELECT <br />
mastid,<br />
houseid as fid,<br />
ST_Distance(ageom, bgeom) as near_dist,<br />
ST_X(ST_Endpoint(shortline))-ST_X(ST_Startpoint(shortline)) as near_x,<br />
ST_Y(ST_Endpoint(shortline))-ST_Y(ST_Startpoint(shortline)) as near_y,<br />
ST_Azimuth(ST_Startpoint(shortline),ST_Endpoint(shortline))/(2*pi())*360
as near_angle,<br />
shortline as the_geom /*just for showing the line on the map*/<br />
from <br />
(<br />
SELECT distinct on (mastid) mastid, houseid, a.the_geom as ageom,
b.the_geom as bgeom, ST_Shortestline(a.the_geom, b.the_geom) as
shortline <br />
FROM phone_masts a, houses b <br />
WHERE ST_DWithin(a.the_geom, b.the_geom, 50000) <br />
ORDER BY a.mastid, ST_Distance(a.the_geom, b.the_geom)<br />
) subq;<br />
<br />
I wrote it with a subquery to save some rewriting.<br />
<br />
then to use it in QGIS you just put <br />
create table a_new_fancy_table_name as<br />
in front of the query and run it all together and to get a unique id you afterwards run<br />
<br />
alter table your_new_fancy_table_name add column gid serial unique;<br />
<br />
then you will get a new column automatically filled. You also get a constraint that tells that the value in the field has to be unique.<br />
<br />
<br />
Cheers<br />
Nicklas<br />
<br />
<br />
2010-05-26 whollycow wrote:<br />
<br />
Is anyone aware of a function equivalent to "Near" in ArcGIS?
(see <a href="http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Near_(Analysis)" target="_blank">webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Near_(Analysis)</a> for reference)
I have been searching all day and haven't come across anything quite like it. It seems like such basic functionality I would be surprised if someone hasn't already coded a solution.
<br />
><hr />
View this message in context: <a href="http://osgeo-org.1803224.n2.nabble.com/QGIS-Near-tp5105804p5105804.html" target="_blank">QGIS "Near"</a><br />
>
Sent from the <a href="http://osgeo-org.1803224.n2.nabble.com/qgis-user-f2036571.html" target="_blank">qgis-user mailing list archive</a> at Nabble.com.<br />
>
</body>
</html>