Sorry, I found out I sent this only to Carson, and not to the list, so I'm forwarding the messagge to the list. Has anyone worked on a "Near" plugin, or something similar?<div><br><br><div class="gmail_quote">
---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Zoran Jankovic</b> <span dir="ltr"><<a href="mailto:zoran.jankovic@zisis.hr">zoran.jankovic@zisis.hr</a>></span><br>Date: Sun, Oct 17, 2010 at 11:26 PM<br>
Subject: Re: [Qgis-user] QGIS "Near"<br>To: <a href="mailto:carson.farmer@gmail.com">carson.farmer@gmail.com</a><br><br><br>Carson,<div><br></div><div>Have you, by any chance, pursued this idea further? I would be very much interested in a plugin that could determine the closest point feature, and select it, from the selected layer, when clicked anywhere on the map. Or, closest to the preselected feature.</div>

<div><br></div><div>Example:</div><div><br></div><div>I have a lot of points that represent hydrants. This layer is selected in the list. I choose this hypothetical "Near" function from the menu, and click anywhere on the map. The closest hydrant to where I clicked is selected.</div>

<div><br></div><div>Example 2:</div><div><br></div><div>Same as previous, but I do not have to click, I can select an already existing point and than have the nearest hydrant to this point selected.</div><div><br></div><div>

It is crucial that I do not want to create any new layers, define "to" and "from" layers, etc. In the case of clicking on the map, there shouldn't be any new point created...</div><div><br></div><div>

I would just need the nearest feature selected.</div><div><br></div><div>Bonus: if the nearest feature could be a line, polyline or a polygon, not just a point.</div><div><br></div><div>I'm aware that all of the above is already possible to accomplish in PostGIS, but this way it would be much simpler, and it would work regardless of data source: shp, postgis... as long as it is a vector layer in QGIS...</div>

<div><br></div><div>I'm very close to implementing QGIS here in my hometown, and if I manage to actually earn any money from this, I would be more than happy to sponsor the development of such a plugin, for a reasonable price. The problem is I need the functionality now, and the money is yet to be earned :-(.</div>

<div><br></div><div>Best regards,</div><div><br></div><font color="#888888"><div>Zoran Jankovic</div><div><a href="http://www.zisis.hr" target="_blank">www.zisis.hr</a></div></font><div><div></div><div class="h5"><div><br>
</div><div><br></div><div><br><div class="gmail_quote">On Mon, May 31, 2010 at 1:11 PM, Carson Farmer <span dir="ltr"><<a href="mailto:carson.farmer@gmail.com" target="_blank">carson.farmer@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">No plugin that I know of, but it could probably be done quite easily<br>
from the Python console,<br>
something to the tune of (untested!):<br>
<br>
layer = qgis.utils.iface.mapCanvas().layer(0)<br>
provider = layer.dataProvider()<br>
provider.select([])<br>
feat = QgsFeature()<br>
index = QgsSpatialIndex()<br>
while provider.nextFeature(feat):<br>
    index.insertFeature(feat)<br>
provider.select([])<br>
while provider.nextFeature(feat):<br>
    near = index.nearestNeighbour(feat.geometry().asPoint(),1)<br>
    nearest = near[0]<br>
    # now do something here with the two points... and output results<br>
as you like<br>
<br>
# Obviously you'd have a bit more work to do here to compute angles<br>
etc. but all this functionality is available via the QGIS API...<br>
# If I get a chance, I might try to add this to the fTools/Vector menu...<br>
<br>
Regards,<br>
<br>
Carson<br>
<div><div></div><div><br>
On 26 May 2010 22:13, whollycow <<a href="mailto:sjgardner@wisc.edu" target="_blank">sjgardner@wisc.edu</a>> wrote:<br>
> Is anyone aware of a function equivalent to "Near" in ArcGIS? (see<br>
> <a href="http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Near_(Analysis)" target="_blank">http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Near_(Analysis)</a><br>
> for reference) I have been searching all day and haven't come across<br>
> anything quite like it. It seems like such basic functionality I would be<br>
> surprised if someone hasn't already coded a solution.<br>
> ________________________________<br>
> View this message in context: QGIS "Near"<br>
> Sent from the qgis-user mailing list archive at Nabble.com.<br>
><br>
</div></div><div>> _______________________________________________<br>
> Qgis-user mailing list<br>
> <a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
> <a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
><br>
><br>
<br>
<br>
<br>
</div><font color="#888888">--<br>
Carson J. Q. Farmer<br>
ISSP Doctoral Fellow<br>
National Centre for Geocomputation<br>
National University of Ireland, Maynooth,<br>
<a href="http://www.carsonfarmer.com/" target="_blank">http://www.carsonfarmer.com/</a><br>
</font><div><div></div><div>_______________________________________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
</div></div></blockquote></div><br></div>
</div></div></div><br></div>