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.
|
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. The GRASS module v.distance should do what you want (available in QGIS's GRASS toolbox). You'll probably also need the v.db.addcol module to prepare relevant columns in the first point vector's attrib table for the feature_id, x, y, dist, etc. of the nearest features in the second vector. -- Micha
-- Micha Silver http://www.surfaces.co.il/ Arava Development Co. +972-52-3665918 _______________________________________________ Qgis-user mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/qgis-user |
In reply to this post by whollycow
Hallo
>From Esri perspective I don't think you should consider it basic functionality since it requires ArcInfo license. 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. 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 :-) 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 Here comes an example where I have tried to do it as similar as the near function as possible. You can run it here: http://www.postgisonline.org/map.php 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. 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" 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. 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. Here it comes, just copy it into the big textarea and press "Map 1" and choose background map as desribed above SELECT mastid, houseid as fid, ST_Distance(ageom, bgeom) as near_dist, ST_X(ST_Endpoint(shortline))-ST_X(ST_Startpoint(shortline)) as near_x, ST_Y(ST_Endpoint(shortline))-ST_Y(ST_Startpoint(shortline)) as near_y, ST_Azimuth(ST_Startpoint(shortline),ST_Endpoint(shortline))/(2*pi())*360 as near_angle, shortline as the_geom /*just for showing the line on the map*/ from ( 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 FROM phone_masts a, houses b WHERE ST_DWithin(a.the_geom, b.the_geom, 50000) ORDER BY a.mastid, ST_Distance(a.the_geom, b.the_geom) ) subq; I wrote it with a subquery to save some rewriting. then to use it in QGIS you just put create table a_new_fancy_table_name as in front of the query and run it all together and to get a unique id you afterwards run alter table your_new_fancy_table_name add column gid serial unique; 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. Cheers Nicklas 2010-05-26 whollycow wrote: Is anyone aware of a function equivalent to "Near" in ArcGIS? (see 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 [hidden email] http://lists.osgeo.org/mailman/listinfo/qgis-user |
On Thu, 2010-05-27 at 20:57 +0200, Nicklas Avén wrote:
> Hallo .... > Here comes an example where I have tried to do it as similar as the > near function as possible. > You can run it here: > http://www.postgisonline.org/map.php > The query searches for the houses closest to the three phone_masts. ... > Cheers > Nicklas > > A bit off topic, but http://www.postgisonline.org/ has only three tutorials on postgis examples. If anyone has any similar links, please can email them (or at the list) to me? -- nikos ves <[hidden email]> _______________________________________________ Qgis-user mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/qgis-user |
In reply to this post by whollycow
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 <[hidden email]> 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 > [hidden email] > 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 [hidden email] http://lists.osgeo.org/mailman/listinfo/qgis-user |
With GDAL 1.7.2, released 2010/04/23, I used gdalbuildvrt to build a .vrt file that points to 726 GeoTIFF images. Then, I use QGIS 1.5.0, release 13519M to pan and zoom through these images. When zoomed in, how do I get Qgis to identify which ONE of the raster images is currently being displayed? Greg
_______________________________________________ Qgis-user mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/qgis-user |
In reply to this post by Carson Farmer
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 <[hidden email]> Date: Sun, Oct 17, 2010 at 11:26 PM Subject: Re: [Qgis-user] QGIS "Near" To: [hidden email] 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 On Mon, May 31, 2010 at 1:11 PM, Carson Farmer <[hidden email]> wrote: No plugin that I know of, but it could probably be done quite easily _______________________________________________ Qgis-user mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/qgis-user |
Hi Zoran,
I believe the infrastructure of what you want is already wihtin the selection and identify tools in QGIS. Isn't this almost implemented in the current identify tool? The current identify tool selects "near" or "close by" features within a certain tolerance. This tolerance can be set in "Options" --> "Map tools" "search radius". I believe it currently only effects the identify tool. Do you want the same tolerance also be used for the click-selection tool? Are you also aware that in QGIS 1.6 there are new selection tools? * by click * by rectangle * by polygon * by freehand * by radius Maybe this also helps to address your needs? Of course you can combine it with previous selections by pressing the ctrl key. Andreas On Tue, October 19, 2010 9:33 am, Zoran Jankovic wrote: > 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 <[hidden email]> > Date: Sun, Oct 17, 2010 at 11:26 PM > Subject: Re: [Qgis-user] QGIS "Near" > To: [hidden email] > > > 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 > <[hidden email]>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 <[hidden email]> 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 >> > [hidden email] >> > 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 >> [hidden email] >> http://lists.osgeo.org/mailman/listinfo/qgis-user >> > _______________________________________________ > Qgis-user mailing list > [hidden email] > http://lists.osgeo.org/mailman/listinfo/qgis-user > -- Andreas Neumann http://www.carto.net/neumann/ http://www.svgopen.org/ _______________________________________________ Qgis-user mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/qgis-user |
On Tue, Oct 19, 2010 at 9:55 AM, Andreas Neumann <[hidden email]> wrote:
Hi Zoran, It sort of is, but not completely. Identify will ID all the features within certain radios (percentage of extent), but it will ID _all_ of the features within this radius. I only need the nearest, no matter how far away... Let us say it is, for simplicity, within current extent.
The current identify tool selects "near" or "close by" features within a Look above. This could be useful, but it is not the functionality I'm currently looking after. Are you also aware that in QGIS 1.6 there are new selection tools? Yup, these are great, but they all select _multiple_ features within radius, rectangle, etc. Maybe this also helps to address your needs? BR, --- Zoran Jankovic ZIS-Izrada softvera i savjetovanje / ZIS - Software Development and Consulting http://www.zisis.hr M: 00 385 98 682 902 T: 00 385 44 683 374 A. Senoe 4 44320 Kutina Croatia _______________________________________________ Qgis-user mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/qgis-user |
In reply to this post by whollycow
Does the function 'snapWithContext'
http://doc.qgis.org/head/classQgsVectorLayer.html#733b974dce13d587e05cf3d4fc24f208 which "Snaps to segment or vertex within given tolerance." seem like what you're looking for? I came across it while trying to get Quantum Navigator working recently...seemed relative, but I'm no expert! ~joe On Tue, Oct 19, 2010 at 9:55 AM, Andreas Neumann <a.neumann at carto.net>wrote: > Hi Zoran, > > I believe the infrastructure of what you want is already wihtin the > selection and identify tools in QGIS. Isn't this almost implemented in the > current identify tool? > > It sort of is, but not completely. Identify will ID all the features within certain radios (percentage of extent), but it will ID _all_ of the features within this radius. I only need the nearest, no matter how far away... Let us say it is, for simplicity, within current extent. > The current identify tool selects "near" or "close by" features within a > certain tolerance. This tolerance can be set in "Options" --> "Map tools" > "search radius". I believe it currently only effects the identify tool. Do > you want the same tolerance also be used for the click-selection tool? > > Look above. This could be useful, but it is not the functionality I'm currently looking after. > Are you also aware that in QGIS 1.6 there are new selection tools? > > * by click > * by rectangle > * by polygon > * by freehand > * by radius > > Yup, these are great, but they all select _multiple_ features within radius, rectangle, etc. > Maybe this also helps to address your needs? > > Of course you can combine it with previous selections by pressing the ctrl > key. > > BR, --- Zoran Jankovic ZIS-Izrada softvera i savjetovanje / ZIS - Software Development and Consulting http://www.zisis.hr M: 00 385 98 682 902 T: 00 385 44 683 374 A. Senoe 4 44320 Kutina Croatia _______________________________________________ Qgis-user mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/qgis-user |
Hi Joe,
On Wed, Oct 20, 2010 at 5:06 PM, Joe Larson <[hidden email]> wrote: Does the function 'snapWithContext' This is similar to the mentioned solution with selecting by radius, or changing the tolerance of ID tool. Close, but no cigar. Since this is not very urgent, I've decided to continue pursuing that outlined solution Carson gave, and write a plugin i Python based on that. Since I actually never used Python before, it may take a while, but hey, I get to learn sth. new :-).
I never got the word back from Carson, has he developed anything along these lines, but I have to presume he didn't... Anyone interested in joning me, or even earning some money, is still invited to jump on board. My GIS implementation project is well on the way, and it seems there'll even be some money involved :-).
Zoran ~joe _______________________________________________ Qgis-user mailing list [hidden email] http://lists.osgeo.org/mailman/listinfo/qgis-user |
Free forum by Nabble | Edit this page |