17.4. Rularea primului nostru algoritm. Setul de instrumente

Note

În această lecție vom rula primul nostru algoritm pentru a obține un prim rezultat.

Așa cum am menționat deja, cadrul de procesare poate rula algoritmi ai altor aplicații, dar conține, de asemenea, algoritmi nativi care nu au nevoie de nici un software extern pentru a rula. Pentru a începe explorarea cadrului de procesare, vom rula unul dintre algoritmii nativi. În particular, vom calcula centroizii setului de poligoane.

În primul rând, deschideți proiectul QGIS corespunzător acestei lecții. Acesta conține doar un singur strat, cu două poligoane

../../../_images/canvas.png

Now go to the text box at the top of the toolbox. That is the search box, and if you type text in it, it will filter the list of algorithms so just those ones contaning the entered text are shown. Type centroids and you should see something like this.

../../../_images/toolbox.png

Caseta de căutare reprezintă un mod foarte practic de a găsi un algoritm.

Pentru a executa un algoritm, trebuie doar să faceți dublu-clic pe numele său, în caseta de instrumente. Când faceți dublu clic pe algoritmul Centroizi, veți vedea următorul dialog.

../../../_images/centroids1.png

All algorithms have a similar interface, which basically contains input parameters that you have to fill, and outputs that you have to select where to store. In this case, the only inputs we have are a vector layer with polygons and a selector to select whether we want several centroids for a single feature in case it is a multipart feature, or the algorithm should generate just one centroid for each feature.

Select the Polygons layer as input. The other field will have no effect at all, since the input layer has no multi-part features.

The algorithm has a single output, which is the centroids layer. There are two options to define where a data output is saved: enter a filepath or save it to a temporary filename

In case you want to set a destination and not save the result in a temporary file, the format of the output is defined by the filename extension. To select a format, just select the corresponding file extension (or add it if you are directly typing the filepath instead). If the extension of the filepath you entered does not match any of the supported ones, a default extension (usually .dbf for tables, .tif for raster layers and .shp for vector ones) will be appended to the filepath and the file format corresponding to that extension will be used to save the layer or table.

In all the exercises in this guide, we will be saving results to a temporary file, since there is no need to save them for a later use. Feel free to save them to a permament location if you want to.

Notice that temporary files are deleted once you close QGIS. If you create a project with an output that was saved as a temporary output, QGIS will complain when you try to open back the project later, since that output file will not exist.

După ce ați configurat dialogul algoritmului, apăsați Run pentru a-i începe execuția.

Veți obține rezultatul următor.

../../../_images/canvas2.png

The output has the same CRS as the input. Geoalgorithms assumes all input layers share the same CRS and do not perform any reprojection. Except in the case of some special algorithms (for instance, reprojection ones), the outputs will also have that same CRS. We will see more about this soon.

Try yourself saving it using different file formats (use, for instance, shp and geojson as extensions). Also, if you do not want the layer to be loaded in QGIS after it is generated, you can check off the check box that is found below the output path box.