Skip to content

Commit

Permalink
docs: documentation about the data table
Browse files Browse the repository at this point in the history
  • Loading branch information
mthh committed Dec 18, 2024
1 parent ba98408 commit 1cbebdc
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 11 deletions.
4 changes: 2 additions & 2 deletions docs/data-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Plusieurs opérations sont possibles (certaines sont présentes sous forme d'un
- la construction de conditions (`CASE WHEN ... THEN ... ELSE ... END`).

Afin de créer un nouveau champ, il est nécessaire de spécifier le nom du champ à créer, le type de données (stock, ratio, etc.) et la formule de calcul.
Lorsque la formule est valide, un aperçu des valeurs calculées (3 premières lignes du tableau) est affiché.
Lorsque la formule est valide, un aperçu des valeurs calculées (8 premières lignes du tableau) est affiché.

<ZoomImg
src="./data-table-new-field-zoom.png"
Expand Down Expand Up @@ -119,5 +119,5 @@ Il est possible de supprimer un champ en effectuant un clic droit sur le nom du

## Fermeture du tableau de données

Lors de la fermeture du tableau de données et si des modifications ont été effectuées, une popup de confirmation s'ouvre.
Lors de la fermeture du tableau de données et si des modifications ont été effectuées, un popup de confirmation s'ouvre.
Il est possible de sauvegarder les modifications effectuées en cliquant sur le bouton "Confirmation" ou d'annuler les modifications en cliquant sur le bouton "Annulation".
106 changes: 97 additions & 9 deletions docs/en/data-table.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
# Data table

::: warning

The english version of the documentation is currently under construction.

Some parts are not yet translated and some translations may be incomplete or inaccurate.

:::


The data table is a central element of the Magrit interface.
It allows the user to visualize and modify the data of each layer.

Expand All @@ -30,3 +21,100 @@ With this type of export, entity geometry is not exported (if you require an exp
you can use the "Export" function in the left-hand menu).

## Adding a new field

You can add a new field by clicking on the “New column...” button at the bottom left of the table.

This feature is comparable to the “field calculator” functionality of GIS software such as QGIS.

<ZoomImg
src="/data-table-new-field.png"
alt="Data table - New column"
caption="Data table - New column"
/>

The current fields of the layer are accessible as shortcuts (yellow buttons) as well as three special fields (green buttons):

- `$count`: the number of entities in the layer,
- `$id`: the unique (and internal) identifier of the entity,
- `$area`: the area of the entity (if it is a polygon).

Several operations are possible (some are present as a shortcut - blue buttons):

- basic mathematical operators (`+`, `-`, `*`, `/`),
- mathematical functions (`sqrt`, `exp`, `abs`, `round`, `floor`, `ceil` and `power`),
- string functions (`concat`, `substring`, `lower`, `upper`, `trim` and `replace`),
- comparison operators (`LIKE`, `=`, `!=`, `>`, `>=`, `<` and `<=`), negation (`NOT`) and logical operations (`AND`, `OR`),
- condition construction (`CASE WHEN ... THEN ... ELSE ... END`).

In order to create a new column, it is mandatory to specify the name of the column to be created, the data type
(stock, ratio, etc.) and the calculation formula.
When the formula is valid, a preview of the calculated values (first 8 lines of the table) is displayed.

<ZoomImg
src="/data-table-new-field-zoom.png"
alt="Data table - New column with valid formula"
caption="Data table - New column with valid formula"
/>

When the formula is invalid, an error message is displayed and the preview is not displayed.

<ZoomImg
src="/data-table-invalid-formula1.png"
alt="Data table - New column with invalid formula"
caption="Data table - New column with invalid formula"
/>

<ZoomImg
src="/data-table-invalid-formula2.png"
alt="Data table - New column with invalid formula"
caption="Data table - New column with invalid formula"
/>

### Example of formula

#### Reclassifying quantitative data into qualitative data

Construction of formulas using conditional statements allows you to reclassify quantitative data into qualitative data.
For example, to crate a new column "Type of population" based on the "Population" column with the following classes:

- "Small" for populations less than 1000 inhabitants,
- "Medium" for populations between 1000 and 10000 inhabitants,
- "Large" for populations greater than 10000 inhabitants.

```sql
CASE WHEN Population < 1000 THEN 'Small'
WHEN Population >= 1000 AND Population <= 10000 THEN 'Medium'
ELSE 'Large'
END
```

#### Extracting the departmental code from the INSEE code

To extract the departmental code from the INSEE code, you can use the `substring` function to extract the first two characters of the INSEE code.

```sql
substring(INSEE, 1, 2)
```

#### Calculating the population density of a territory

To calculate the population density of a territory, you can use the following formula:

```sql
Population / Area
```

Let's say that the area is in m² and you want to get a density in hab/km²:

```sql
Population / Area * 1000000
```

## Deleting a field

To delete a field, right-click on the field name and select "Delete column".

## Closing the data table

When you close the data table, a dialog box will appear asking you to save the changes made to the data.
It's possible to save the changes by clicking on the "Confirm" button or to cancel the changes by clicking on the "Cancel" button.

0 comments on commit 1cbebdc

Please sign in to comment.