Fwd: [Qgis-user] QGIS "Near"

Zoran Jankovic zoran.jankovic at zisis.hr
Tue Oct 19 00:33:42 PDT 2010


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?


---------- Forwarded message ----------
From: Zoran Jankovic <zoran.jankovic at zisis.hr>
Date: Sun, Oct 17, 2010 at 11:26 PM
Subject: Re: [Qgis-user] QGIS "Near"
To: carson.farmer at gmail.com


Carson,

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.

Example:

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.

Example 2:

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.

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...

I would just need the nearest feature selected.

Bonus: if the nearest feature could be a line, polyline or a polygon, not
just a point.

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...

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 :-(.

Best regards,

Zoran Jankovic
www.zisis.hr



On Mon, May 31, 2010 at 1:11 PM, Carson Farmer <carson.farmer at gmail.com>wrote:

> No plugin that I know of, but it could probably be done quite easily
> from the Python console,
> something to the tune of (untested!):
>
> layer = qgis.utils.iface.mapCanvas().layer(0)
> provider = layer.dataProvider()
> provider.select([])
> feat = QgsFeature()
> index = QgsSpatialIndex()
> while provider.nextFeature(feat):
>    index.insertFeature(feat)
> provider.select([])
> while provider.nextFeature(feat):
>    near = index.nearestNeighbour(feat.geometry().asPoint(),1)
>    nearest = near[0]
>    # now do something here with the two points... and output results
> as you like
>
> # Obviously you'd have a bit more work to do here to compute angles
> etc. but all this functionality is available via the QGIS API...
> # If I get a chance, I might try to add this to the fTools/Vector menu...
>
> Regards,
>
> Carson
>
> On 26 May 2010 22:13, whollycow <sjgardner at wisc.edu> wrote:
> > Is anyone aware of a function equivalent to "Near" in ArcGIS? (see
> >
> http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Near_(Analysis)
> > 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.
> > ________________________________
> > View this message in context: QGIS "Near"
> > Sent from the qgis-user mailing list archive at Nabble.com.
> >
> > _______________________________________________
> > Qgis-user mailing list
> > Qgis-user at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/qgis-user
> >
> >
>
>
>
> --
> Carson J. Q. Farmer
> ISSP Doctoral Fellow
> National Centre for Geocomputation
> National University of Ireland, Maynooth,
> http://www.carsonfarmer.com/
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20101019/8b08d288/attachment.html>


More information about the Qgis-user mailing list