17.7. Selecția

Notă

În această lecție vom vedea cum gestionează selecțiile algoritmii de procesare din straturile vectoriale care sunt utilizate ca intrare, și cum se poate crea o selecție, folosindu-se un anumit tip de algoritm.

Spre deosebire de alte plugin-uri de analiză din QGIS, geoalgoritmii de procesare nu dispun de caseta de bifare pentru „Utilizare doar a entităților selectate” sau ceva similar acesteia. Comportamentul privitor la selectare este stabilit pentru întreg plugin-ul și pentru toți algoritmii, și nu pentru fiecare rulare a algoritmului. Algoritmii respectă următoarele reguli simple, atunci când se utilizează un strat vectorial.

  • Dacă stratul are o selecție, vor fi utilizate numai entitățile selectate.

  • Dacă nu există nici o selecție, atunci vor fi utilizate toate entitățile.

Vă rugăm să rețineți că puteți schimba acest comportament prin deselectarea meniului opțiunii relevante Processing ► Options ► General`.

You can test that yourself by selecting a few points in any of the layers that we used in the last chapter, and running the reprojection algorithm on them. The reprojected layer that you will obtain will contain only those points that were selected, unless there was no selection, which will cause the resulting layer to contain all points from the original layer.

To make a selection, you can use any of the available methods and tools in QGIS. However, you can also use a geoalgorithm to do so. Algorithms for creating a selection are found in the toolbox under Vector/Selection

../../../_images/selection_algs.png

Deschideți algoritmul de Selecție aleatoare.

../../../_images/random_selection.png

Lăsând valorile implicite, se vor selecta 10 puncte din stratul curent.

../../../_images/selected1.png

Veți observa că acest algoritm nu produce nici o ieșire, dar modifică stratul de intrare (nu stratul în sine, ci selecția sa). Acesta este un comportament mai puțin frecvent, deoarece toți ceilalți algoritmi vor produce noi straturi și nu vor modifica straturile de intrare.

Since the selection is not part of the data itself, but something that only exist within QGIS, these selection algorithms only must be used selecting a layer that is open in QGIS, and not with the file selection option that you can find in the corresponding parameter value box.

The selection we have just made, like most of the ones created by the rest of the selection algorithms, can also be done manually from QGIS, so you might be wondering what is the point on using an algorithm for that. Although now this might not make much sense to you, we will later see how to create models and scripts. If you want to make a selection in the middle of a model (which defines a processing workflow), only a geoalgorithm can be added to a model, and other QGIS elements and operations cannot be added. That is the reason why some processing algorithms duplicate functionality that is also available in other QGIS elements.

By now, just remember that selections can be made using processing geoalgorithms, and that algorithms will only use the selected features if a selection exists, or all features otherwise.