:indexul:`Tabelul de atribute` afișează entitățile unui strat selectat. Fiecare rând din tabel reprezintă o entitate a hărții, iar fiecare coloană conține o anumită informație despre entitate. Entitățile din tabel pot fi căutate, selectate, mutate sau chiar editate.
Pentru a deschide tabelul de atribute pentru un strat vectorial, activați stratul, făcând clic pe el, în zona legendei hărții. Apoi, din meniul principal al Stratului, alegeți Deschiderea Tabelei de Atribute. De asemenea, se poate face clic dreapta pe strat, se alege
Deschiderea Tabelului de Atribute din meniul derulant, apoi se apasă butonul de
Deschidere Tabelă de Atribute din bara de instrumente a Atributelor.
Se va deschide o fereastră nouă care afișează atributele entităților din strat (figure_attributes_1). Numărul de funcții și numărul de entități selectate sunt prezentate în titlul tabelului de atribute.
Figure Attributes 1:
Tabela de Atribute pentru stratul regiunilor
Butoanele din partea de sus a ferestrei tabelei de atribute oferă următoarele funcționalități:
Trecere în modul de editare, pentru editarea funcționalităților (de asemenea, cu
Ctrl+e
)
Deplasare hartă până la rândurile selectate (de asemenea, cu
Ctrl+p
)
Transfocare hartă la nivelul rândului selectat (de asemenea, cu
Ctrl+j
)
Copiere rânduri selectate în clipboard (de asemenea, cu
Ctrl+c
)
Lipire din clipboard într-un nou rând (de asemenea, cu
Ctrl+v
)
Ștergere Coloană pentru straturile PostGIS și OGR cu versiunea GDAL >= 1.9 (de asemenea, cu
Ctrl+l
)
Coloană Nouă pentru straturile PostGIS și OGR cu versiunea GDAL >= 1.6 (de asemenea, cu
Ctrl+w
)
Below these buttons is the Field Calculator bar (enabled only in editing mode),
which allows calculations to be quickly applied to either all or selected features
attributes in the table. This bar uses the same expressions as the
Field Calculator (see Calculatorul de Câmpuri).
Tip
Se omite geometria WKT
If you want to use attribute data in external programs (such as Excel), use the
Copy selected rows to clipboard button.
You can copy the information without vector geometries if you deactivate
Settings ‣ Options ‣ Data sources menu
Copy geometry in WKT representation from attribute table.
Each selected row in the attribute table displays the attributes of a selected feature in the layer. If the set of features selected in the main window is changed, the selection is also updated in the attribute table. Likewise, if the set of rows selected in the attribute table is changed, the set of features selected in the main window will be updated.
Rows can be selected by clicking on the row number on the left side of the
row. Multiple rows can be marked by holding the Ctrl
key.
A continuous selection can be made by holding the Shift
key and
clicking on several row headers on the left side of the rows. All rows
between the current cursor position and the clicked row are selected.
Moving the cursor position in the attribute table, by clicking a cell in the
table, does not change the row selection. Changing the selection in the main
canvas does not move the cursor position in the attribute table.
The table can be sorted by any column, by clicking on the column header. A small arrow indicates the sort order (downward pointing means descending values from the top row down, upward pointing means ascending values from the top row down).
For a simple search by attributes on only one column, choose the Column filter ‣ from the menu in the bottom left corner. Select the field (column) on which the search should be performed from the drop-down menu, and hit the [Apply] button. Then, only the matching features are shown in the attribute table.
To make a selection, you have to use the Select features using an Expression
icon on top of the attribute table.
Select features using an Expression allows you
to define a subset of a table using a Function List like in the
Field Calculator (see Calculatorul de Câmpuri).
The query result can then be saved as a new vector layer.
For example, if you want to find regions that are boroughs from
regions.shp
of the QGIS sample data, you have to open the Fields and Values menu
and choose the field that you want to query. Double-click the field ‘TYPE_2’ and also
[Load all unique values] . From the list, choose and double-click ‘Borough’.
In the Expression field, the following query appears:
"TYPE_2" = 'Borough'
Here you can also use the Function list ‣ Recent (Selection) to make a selection that you used before. The expression builder remembers the last 20 used expressions.
The matching rows will be selected, and the total number of matching rows will appear in the title bar of the attribute table, as well as in the status bar of the main window. For searches that display only selected features on the map, use the Query Builder described in section Constructorul de Interogări.
To show selected records only, use Show Selected Features from the menu at the bottom left. See next section for more information on filter feature.
The field calculator bar allows you to make calculations on the selected rows only.
For example, you can alter the number of the ID field of the layer regions.shp
with the expression
ID+5
așa cum se arată în figure_attributes_1 .
În partea de jos a tabelului de atribute, aveți o listă cu derulare verticală a unui filtru diferit:
Afişează Toate Entitățile;
Afişează Entitățile Selectate;
Afișează Entitățile vizibile pe hartă;
Afișează Entitățile Noi și pe cele Editate;
Filtru de Câmp;
Filtru avansat (Expresie);
The first four are self explanatory, the two last are expression filters. Field Filter allows user to choose a column name in the list and add a simple form to the right of the drop-down list to filter with a like expression parameter. This filter will create an expression filter as an Advanced filter. The last kind of filter will open an expression window, see Expresii for more information.
În mod implicit fereastra de atribute are forma unui tabel. În unele cazuri, ar trebui să preferați să utilizarea unui aspect de formular, care va facilita editarea unor entități.
You can switch to form layout by clicking in the bottom right, on
and switch back to table layout with
.
To zoom into a feature, without having to select it, right-click on the feature you want to zoom in, within the attribute table, and select Zoom to feature.
Entitățile selectate pot fi salvate în orice alt format vectorial acceptat de OGR și, de asemenea, pot fi reproiectate într-un alt sistem de coordonate de referință (CRS). Trebuie doar să deschideți, printr-un clic dreapta, meniul stratului și să faceți clic pe Salvare ca pentru a defini numele fișierului de ieșire, formatul și CRS-ul său (consultați secțiunea Panoul Straturilor). Pentru a salva selecția, asigurați-vă că este selectată opțiunea de Salvare doar a entităților selectate. De asemenea, în cadrul dialogului este posibilă specificarea opțiunilor de creare OGR.
Features that are on the clipboard may be pasted into a new layer. To do this, first make a layer editable. Select some features, copy them to the clipboard, and then paste them into a new layer using Edit ‣ Paste Features as and choosing New vector layer or New memory layer.
This applies to features selected and copied within QGIS and also to features from another source defined using well-known text (WKT).
The Field Calculator button in the attribute
table allows you to perform calculations on the basis of existing attribute values or
defined functions, for instance, to calculate length or area of geometry features. The
results can be written to a new attribute field, a virtual field, or
they can be used to update values in an existing field.
A virtual field is a field based on an expression calculated on the fly,
meaning that its value is automatically updated as soon as the underlying parameter
changes. The expression is set once; you no longer need to recalculate the field
each time underlying values change.
For example, you may want to use a virtual field if you need area to be evaluated
as you digitize features or to automatically calculate a duration between dates
that may change (e.g., using now()
function).
Note
Utilizarea Câmpurilor Virtuale
The field calculator is available on any layer that supports edit. When you click on the field calculator icon the dialog opens (see figure_attributes_2). If the layer is not in edit mode, a warning is displayed and using the field calculator will cause the layer to be put in edit mode before the calculation is made.
The quick field calculation bar on top of the attribute table is only visible if the layer is in edit mode.
In quick field calculation bar, you first select the existing field name then open the expression dialog to create your expression or write it directly in the field then click on [Update All], [Update Selected] or [Update Filtered] button according to your need.
Based on the Expression Builder dialog, the field calculator dialog offers a complete interface to define an expression and apply it to an existing or a newly created field. To use the field calculator dialog, you first must select whether you want to only update selected features, create a new attribute field where the results of the calculation will be added or update an existing field.
Figure Attributes 2:
Calculatorul de Câmpuri
If you choose to add a new field, you need to enter a field name, a field type (integer, real or string), the total field width, and the field precision (see figure_attributes_2). For example, if you choose a field width of 10 and a field precision of 3, it means you have 6 digits before the dot, then the dot and another 3 digits for the precision.
A short example illustrates how field calculator works when using the
Expression tab. We want to calculate the length in km of the
railroads
layer from the QGIS sample dataset:
Încărcați fișierul shape railroads.shp
în QGIS și efectuați pe Deschiderea Tabelei de Atribute.
Clic pe Comutare în modul de editiare, apoi deschideți dialogul
Calculatorului de Câmpuri.
Selectați caseta de bifare pentru Crearea unui nou câmp, în scopul salvării calculelor într-un nou câmp.
length
as Output field name and real
as Output field type, and
define Output field width to be 10 and Precision, 3.Acum, faceți dublu clic pe funcția $length
din grupul Geometry pentru a-l adăuga în Câmpul calculatorului de expresii.
Completați expresia introducând / 1000
în caseta de expresii a Calculatorului de câmpuri, și făcând clic pe [Ok].
Acum, puteți găsi noul câmp length
în tabelul de atribute.
QGIS allows you also to load non-spatial tables. This currently includes tables
supported by OGR and delimited text, as well as the PostgreSQL, MSSQL and Oracle provider.
The tables can be used for field lookups or just generally browsed and edited using the table
view. When you load the table, you will see it in the legend field. It can be
opened with the Open Attribute Table tool and
is then editable like any other layer attribute table.
As an example, you can use columns of the non-spatial table to define attribute values, or a range of values that are allowed, to be added to a specific vector layer during digitizing. Have a closer look at the edit widget in section Meniul Câmpurilor to find out more.
You can enable the conditional formatting panel clicking on
at the top right of the attributes window in table
view (not available in form view).
The new panel allows user to add new rules for conditional formatting of field or full row in regard of the expression on field. Adding new rule open a form to define:
defini numele regulii,
o condiție din fereastra de expresii,
o formatare presetată
câțiva alți parametri pentru a îmbunătăți, modifica sau seta formatarea:
culori de fundal sau pentru text,
utilizarea pictogramei,
îngroșarea, sublinierea, înclinarea sau tăierea textului,
câmpul textului,
fontul.
Figure Attributes 3:
Formatarea condițională a unei tabelelor cu atribute
Relations are a technique often used in databases. The concept is, that features (rows) of different layers (tables) can belong to each other.
As an example you have a layer with all regions of alaska (polygon) which provides some attributes about its name and region type and a unique id (which acts as primary key).
Then you get another point layer or table with information about airports that are located in the regions and you also want to keep track of these. If you want to add them to the region layer, you need to create a one to many relation using foreign keys, because there are several airports in most regions.
Figure Relations 1:
Regiunile cu aeroporturi din Alaska
In addition to the already existing attributes in the airports attribute table another field fk_region which acts as a foreign key (if you have a database, you will probably want to define a constraint on it).
This field fk_region will always contain an id of a region. It can be seen like a pointer to the region it belongs to. And you can design a custom edit form for the editing and QGIS takes care about the setup. It works with different providers (so you can also use it with shape and csv files) and all you have to do is to tell QGIS the relations between your tables.
QGIS makes no difference between a table and a vector layer. Basically, a vector layer is a table with a geometry. So can add your table as a vector layer. To demonstrate you can load the ‘region’ shapefile (with geometries) and the ‘airport’ csv table (without geometries) and a foreign key (fk_region) to the layer region. This means, that each airport belongs to exactly one region while each region can have any number of airports (a typical one to many relation).
Primul lucru pe care îl vom face este de a indica aplicației QGIS despre relațiile din cadrul stratului. Acest lucru se face în Proiect ‣ Proprietățile Proiectului. Deschideți meniul Relațiilor și faceți clic pe Adăugare.
numele va fi folosit ca titlu. Acesta ar trebui să fie un șir de caractere ușor de citit, care descrie la ce folosește relația. Vom folosi “Airports” în acest caz.
Figure Relations 2:
Managerul de Relații
Now that QGIS knows about the relation, it will be used to improve the forms it generates. As we did not change the default form method (autogenerated) it will just add a new widget in our form. So let’s select the layer region in the legend and use the identify tool. Depending on your settings, the form might open directly or you will have to choose to open it in the identification dialog under actions.
Figure Relations 3:
Dialogul de identificare a regiunilor, cu relațiile între aeroporturi
As you can see, the airports assigned to this particular region are all shown in a table. And there are also some buttons available. Let’s review them shortly
Cele două butoane din dreapta comută între vederea sub formă de tabelă și cea sun formă de formular, care, mai târziu, vă vor permite vizualizarea tuturor aeroporturilor.
If you work on the airport table, a new widget type is available which lets you embed the feature form of the referenced region on the feature form of the airports. It can be used when you open the layer properties of the airports table, switch to the Fields menu and change the widget type of the foreign key field ‘fk_region’ to Relation Reference.
If you look at the feature dialog now, you will see, that the form of the region is embedded inside the airports form and will even have a combobox, which allows you to assign the current airport to another region.
Figure Relations 4:
Dialogul de identificare a aeroportului, cu relațiile între regiuni