4

I'm working in QGIS 2.18.3.

I have point layer which represents GPS points along a transect line. I would like to randomly select 5 points along this transect, i.e. from this layer.

Somehow I expected this to be straight forward, but I seem to miss something here.

I used Research Tools --> Random selection within subset, selected the transect as input layer, Latitude as ID Field (Latitude = Real), Number of selected features (for the count instead of percentage) and entered 5 as number of selected features.

After pressing "Run" the process runs without problems as the process bar proceeds to 100%, then closes and I receive no error message.

However, nothing has been selected, i.e. no 5 points are highlighted in the attribute table (header still shows selected=0).

Am I using the function in a wrong way or do I expect the wrong output?

underdark
  • 84,148
  • 21
  • 231
  • 413
AstridH
  • 43
  • 4
  • Could you provide some more information: what version of qgis, error message or result output? After running the tool and you don't get any errors, it should be fine. Cross check the by opening the attribute table, the header would show you how many were selected. You should check that you chose the right input layer and you clicked all the right fields of the tool. – mapperx Mar 29 '17 at 17:49
  • is it selecting nothing, or is it selecting everything? is your latitude field a float/real number, that might cause problems? – Steven Kay Mar 29 '17 at 19:22
  • Thanks for your prompt reply, much appreciated. I have updated the post and added the requested information. Sorry for not being detailed enough - I'm new to this game. Thanks for trying to help :)! – AstridH Mar 30 '17 at 08:12
  • "The percentage/count value is not applied to the whole layer, but instead to each category. Categories are defined according to a given attribute, which is also specified as an input parameter for the algorithm." - not sure you need this method. Here is an example of using the 'Random selection within subset'. I believe you need to use 'Random selection' method for this task. – Mykola Kozyr Mar 30 '17 at 08:42
  • Thanks for reply Mykola! I seem to have the same issue there, i.e. the process runs, finishes and nothing else happens. I tried it now on a different layer with float numbers and there it seem to work. So, I assume Steven was right when he suggested the float/real number could cause problems. Any ideas on how I can tackle this problem? – AstridH Mar 30 '17 at 09:02
  • I now added another field to the attribute table (ID number) and used this to randomly select my points and surprisingly this seems to work. A rather complicated work around to a very easy task, but I don't have too many transects, so this will be ok for now. Thanks for all your suggestions, much appreciated :)! – AstridH Mar 30 '17 at 09:27
  • So, you determine the same value in ID_field for points along every transect (categorizing features), right? In this case why not to use 'Join attributes by location'? – Mykola Kozyr Mar 30 '17 at 09:47
  • And yes, I didn't get from the description you got a bunch of transects in your layer, so 'Random selection' is definitely not the best option here :) – Mykola Kozyr Mar 30 '17 at 09:58

1 Answers1

1

One way to do this might be to:

  • export your subset to another layer
  • add a field to the attribute table, type float
  • calculate random numbers using the Field Calculator for each cell
  • pick the 5 highest (or lowest) numbers.
Paulo Raposo
  • 1,930
  • 14
  • 21