[Qgis-user] How to select only one point from each polygon?

Nicolas Cadieux nicolas.cadieux at archeotec.ca
Sat May 9 07:59:47 PDT 2015


Idea's only... Not solutions 
Id the polygon with a number (polynum) 
Use spatial query on the points to figure out in which polygons they fall Into.  Return polygons id number to points. (Polynum field) 
Export point.shp to points.txt file then to a spread sheet like Excel or Libre office calc. 
There, you need a few columns. 
Point unique id 
Polygon number for each point (polynum) 
A field to count the amount of points with the same polygons number (pointcount) 
A field (called pointnum) that will add a number 1 to x (x is the max number of points for each polygon based on pointcount) this numbering will need to restart to 1 for each polygon.  
And for each polygon id number (polynum) ,I would randomly select a number between 0 and x.  This is a normal function in a spreadsheet. (random field) 
Export the point.txt file back to Qgis. 
All this will help you create a query that you will do in QGIS 
It will go like this in the field calculator: 
Create a new field that will receive the answers (1 and 0) 
Case 
When  "polynum" = 1 and "random" = 5 then 1 
When "polynum" = 2 and "random" = 23 then 1 
When "polynum" = 3 and "random" = 76 then 1 
... 
Else 0 
End 
Then all you need to do is select the points base on answer field. 
You can build this query in Excel and then export to .txt file. 
To do this in a spreadsheet, you will need functions like loops,  vlookup and hlookup, filtering unique values and possibly xtabs or cross tables. 
Hope this helps. 
(If it doesn't, just randomly click like hell on your screen and hope you get it right!) :) 
Nicolas Cadieux M.Sc. 
Les Entreprises Archéotec inc.  
8548, rue Saint-Denis Montréal H2P 2H2 
Téléphone: 514.381.5112  Fax: 514.381.4995 
www.archeotec.ca 




--
View this message in context: http://osgeo-org.1560.x6.nabble.com/How-to-select-only-one-point-from-each-polygon-tp5204951p5204971.html
Sent from the Quantum GIS - User mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20150509/5e47f25c/attachment.html>


More information about the Qgis-user mailing list