66

I'm using QGIS 1.8 with a PostGIS database and I have three PostGIS layers in QGISL: a lines, a points, and a polygon.

I'm trying to select features in the polygon layer and mark all points within this polygon.

For me the only way to do this is to use the button "Select by Polygon" but in this way, I cannot use an existing polygon for selection.

Taras
  • 32,823
  • 4
  • 66
  • 137
Novice
  • 661
  • 1
  • 5
  • 3

2 Answers2

79

Two possible solutions:

  1. You can use the "Select by Location" from Vector > Research tools > Select by Location and tick the "Use selected features only" checkbox.
  2. If you want to actually export the points which intersect your selected polygon to a new shapefile then "Intersection" from Vector > Geopressing tools > Intersection and again tick the "Use only selected features" checkbox. The input layer will be your points layer, and the select layer will be your polygon layer.
Taras
  • 32,823
  • 4
  • 66
  • 137
Micha
  • 15,555
  • 23
  • 29
  • Furthermore, am I correct in adding that for the Vector processing to work, the following two conditions need to be met: [1.] The layers need to have the same CRS; and [2.] The layer needs to be selected in the 'Layers' panel. – Gonja Apr 05 '16 at 14:26
  • 1
    I do not have "Use only selected features" checkbox, see https://www.dropbox.com/s/hw2d422gh6wmoxm/Screenshot%202017-04-18%2011.40.41.png?dl=0 ? I have 2 layers, selected, and an object selected in one of the layers. – JaakL Apr 18 '17 at 08:43
  • 2
    Take care when the layers are too large - they must be loaded into QGIS as a whole, which may be slow. It may be better to use a PostGIS query (e. g. via the DB Manager) instead. – Jan Šimbera Jan 22 '18 at 08:49
  • @JaakL I had the same problem, but as you can see in the response below, the default behavior is to use the selected features if any: https://gis.stackexchange.com/a/257060/121285 – nanocv Sep 17 '18 at 11:19
  • The intersect tool works so-so in edge/boundary conditions, I would suggest trying the Select Within plugin suggested below – Justin Kray Nov 10 '18 at 03:07
4

I can suggest using the Select Within Plugin.

Centroid within, point of surface within, pole of inaccessibility within, percentage within, and mostly within selection. Works best with lines and polygons, but should work with other geometries as well.

window

Taras
  • 32,823
  • 4
  • 66
  • 137
  • Yes!!! Tried this tool once & it nailed it. Select by centroid is the behavior I would expect from the default QGIS Select by Location tool, which did not perform very well on edge and boundary conditions. – Justin Kray Nov 10 '18 at 03:06