gvSIG-Desktop 1.11. User manual
“Field calculator” Let us look at a simple example to explain how the field calculator works.
In order to work out the area of a series of plots in a layer we have created:
First, open a gvSIG view and load an orthophoto which will be used as a base to determine the location of the plots. Next, select the tool in order to create a new shp file (View/New layer/SHP).
Select a “Polygon” type layer, click on the “Next” option and then create a “Double” type field called “Area”, leaving the default value at 20.
![calculadora-de-campos/calculadora-de-campos-en.img/NuevaCapaAnyadirCampos_es.png](../../../../../../docusr/acceso-editores/funcionalidades/tablas/calculadora-de-campos/calculadora-de-campos/calculadora-de-campos-en.img/NuevaCapaAnyadirCampos_es.png)
Draw four plots on the orthophoto using the “Insert polyline” tool selected from the tool bar. The image below shows that a record for each of the plots has been created in the table.
![tablas/calculadora-de-campos/calculadora-de-campos-en.img/parcelasDigitalizadas_es.png](../../../../../../docusr/acceso-editores/funcionalidades/tablas/calculadora-de-campos/tablas/calculadora-de-campos/calculadora-de-campos-en.img/parcelasDigitalizadas_es.png)
Select the field from the table and activate the field calculator.
![tablas/calculadora-de-campos/calculadora-de-campos-en.img/botonCalculadoraCampos_es.png](../../../../../../docusr/acceso-editores/funcionalidades/tablas/calculadora-de-campos/tablas/calculadora-de-campos/calculadora-de-campos-en.img/botonCalculadoraCampos_es.png)
![calculadora-de-campos-en.img/ventanaCalculadoraCampos_es.png](../../../../../../docusr/acceso-editores/funcionalidades/tablas/calculadora-de-campos/calculadora-de-campos-en.img/ventanaCalculadoraCampos_es.png)
The following information appears in the “General” tab:
![calculadora-de-campos-en.img/CampoTipoComandosCalculadoraCampos_es.png](../../../../../../docusr/acceso-editores/funcionalidades/tablas/calculadora-de-campos/calculadora-de-campos-en.img/CampoTipoComandosCalculadoraCampos_es.png)
“Field”. This contains the various different fields which comprise the table being worked on.
“Type” of field selected. Access to different commands depends on the type of field.
“Commands” which can be used in the calculations.
The “Information” section shows that:
If the “area” command has been selected in the “General” tab, a brief description will be displayed in the information window.
![calculadora-de-campos-en.img/informacionValorBoleano_es.png](../../../../../../docusr/acceso-editores/funcionalidades/tablas/calculadora-de-campos/calculadora-de-campos-en.img/informacionValorBoleano_es.png)
If the “area” command has been selected in the “General” tab, the information window returns a message with information on the field type (remember that when designing the “area” shape, a Double type numeric field was created in which the area will be calculated).
![calculadora-de-campos-en.img/informacionCalculadoraCampos_es.png](../../../../../../docusr/acceso-editores/funcionalidades/tablas/calculadora-de-campos/calculadora-de-campos-en.img/informacionCalculadoraCampos_es.png)
The “Expression" area displays the name of the column on which the calculation is being performed and a text box for the calculation sentence to be used.
![calculadora-de-campos-en.img/informacionAreaCalculadoraCampos_es.png](../../../../../../docusr/acceso-editores/funcionalidades/tablas/calculadora-de-campos/calculadora-de-campos-en.img/informacionAreaCalculadoraCampos_es.png)
In this case, the sentence included in the expression section is simple (no parameters are required as they are in other expressions which shall be explained later on).
To sum up and conclude this example, once the “area” command has been selected, click on “Ok” and the field created in the table will automatically be filled with the area values of each of the polygons drawn.
![calculadora-de-campos-en.img/tablaResultadosArea_es.png](../../../../../../docusr/acceso-editores/funcionalidades/tablas/calculadora-de-campos/calculadora-de-campos-en.img/tablaResultadosArea_es.png)