Skip to content

Commit

Permalink
Add Edit multiple features attributes lesson
Browse files Browse the repository at this point in the history
  • Loading branch information
SrNetoChan committed Sep 25, 2017
1 parent 27ae1c2 commit 9b8cc30
Show file tree
Hide file tree
Showing 76 changed files with 2,427 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
In previous lessons, we have shown how to edit attributes feature by
feature, using the attribute table or the feature form, and how to
update a column for all the features, using the field calculator. In
this lesson, we will cover how to edit/update only a subset of selected
features and how to edit multiple fields of the selected features.

Click **Next step** when you are ready to start.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
For this lesson, as an example, we will use the *Buildings* layer. We
will simulate that a full block is going to become Commercial, and we
will update the data.

Let's start by selecting all the buildings on the block in the
center of the map canvas.

- In the **Layers Panel**, click the *Buildings* layer to make it active.

![buildings_active_layer](buildings_active_layer.png)

- In the **Attributes toolbar**, click the **Select by area or single
click** to enable it.

![select_tool_button](select_tool_button.png)

- In the map canvas, draw a rectangle around all the buildings in the
block by clicking and dragging, making sure not to cross buildings
outside.

![select_buildings.png](select_buildings.png)

All selected buildings will be rendered in bright yellow.

![buildings_are_selected](buildings_are_selected.png)

Click **Next step** once you are done.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Now that we have some buildings selected, let's open the *Buildings*
layer's attribute table.

- In the Layers Panel, right-click the *Buildings* layer and
choose **Open Attribute Table**.

![open_attribute_table.png](open_attribute_table.png)

- Alternatively, having the *Buildings* layer active,
you can click the **Open Attribute Table** button in the **Attributes
toolbar**.

![open_attribute_table_button.png](open_attribute_table_button.png)

An **Attribute Table** window for the *Buildings* layer will open
listing all of the layer's 536 features attributes in a table with 21
features selected.

![buildings_attribute_table](buildings_attribute_table.png)

Click **Next step** once you are done.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Before you can edit a layer, it must be in Edit mode. There are several
ways of changing a layer to edit mode, but, for our example, using the
button available in the Attribute table is more straightforward.

- In the Attribute table toolbar, click the **Toggle edit mode**.

![toggle_editing_mode.png](toggle_editing_mode.png)

Alternatively, you can use a similar button located in the *Digitizing
toolbar*, in QGIS's main window, or right-click the *Buildings* layer in
the *Layers Panel* and choose *Toggle Editing*.

![toggle_editing_alternatives.png](toggle_editing_alternatives.png)

Click **Next step** once you are done.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
One way to change the attributes of multiple features at the same time is
to use the field calculator. As an example, for now, we want to change
all the selected building to `UNDER CONSTRUCTION`.

- In the **Attribute table** toolbar, click the **Open field
calculator** or press `CTRL + I`.

![open_field_calculator](open_field_calculator.png)

In the **Field Calculator** dialog:

- Enable the *Only update n selected features* option.

![enable_select_only](enable_select_only.png)

- Enable **Update existing field** option and choose the *DESCRIPTIO*
field.

![update_existing_field](update_existing_field.png)

- In the Expression text box, instead of an expression, type in the
value directly, that is `'UNDER CONSTRUCTION'`.

![type_under_construction](type_under_construction.png)

Note the single quotes (') around the value to indicate that the value is a
text string and not some field or variable.

- Click **OK** to update the features and close the **Field calculator**.

Click **Next step** once you are done.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Back in the *Buildings* attribute table, let's confirm that all
the selected features were updated.

- In the **Attribute table** toolbar, click the **Move selection to
top** button.

![move_selection_to_the_top](move_selection_to_the_top.png)

All selected feature attributes are moved to the top, and you can easily
confirm that, for all selected feature, the *DESCRIPTIO* field is now
`UNDER CONSTRUCTION`.

![updated_fields](updated_fields.png)

Click **Next step** once you are done.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Instead of opening the Field calculator dialog every time you want to
update a field for multiple features, you can use the *Quick field
calculator bar*.

When a vector layer is in editing mode, the *Quick field calculator bar*
appears below the attribute table toolbar.

![quick_calculator](quick_calculator.png)

As an example, keeping the same features selected, we will update
the *UPDATE_DAT* field to reflect the new changes.

- Select the *UPDATE_DAT* field from the field combo box.

![select_field_to_update](select_field_to_update.png)

- In the long text box, type in a more recent date, for example,
`'2017-08-15'`. Please mind the single quotes (') around the date.

![quickbar_type_value](quickbar_type_value.png)

- Click the *Update Selected features* button.

![update_selected_button](update_selected_button.png)

You can immediately confirm that the *UPDATE_DAT* field was updated
with the new value.

![updated_date_field](updated_date_field.png)

Click **Next step** once you are done.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Unlike the previous tools, multi edit mode allows multiple attributes
of different features to be edited simultaneously.

For this example, keeping the same features selected, we will change the
*DESCRIPTIO* field to `COMMERCIAL` and update the *UPDATE_DAT* field as
we did before, but, this time, in one single step.

- In the attribute table toolbar, click the **Toggle multi edit** button.

![toggle_multi_edit](toggle_multi_edit.png)

The attribute table will show a form similar to the layer feature form.

![multi_edit_mode](multi_edit_mode.png)

The filled fields with a green icon next to it mean that all
selected features share the same value for that field.

On the opposite, the empty fields with a yellow icon next to it mean
that the selected features have different values for that particular
field.

- In the **DESCRIPTIO** field type `COMMERCIAL` and in the **UPDATE_DAT**
field type `2017-09-24`.

![edited_multiple_fields](edited_multiple_fields.png)

The red icon next to fields indicates that new values were entered,
but they haven't been set to the features yet.

You will also notice a warning message, informing you that the changes
were not committed yet.

- In the Warning message, click **apply changes**.

![apply_multi_edit_changes](apply_multi_edit_changes.png)

A message should inform you that the changes have been applied. Please
notice that, at this point, the **changes were not saved into the data
source yet**, it only updates the fields values for each of the selected
features.

Click **Next step** once you are done.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
To confirm that the changes to the fields were in fact applied, let's turn off
the multi edit mode, and go back to table view.

- In the attribute table toolbar, click the **Toggle multi edit** button.

![toggle_multi_edit](toggle_multi_edit.png)

- In the attribute table bottom-right corner, click the **Switch to
table view** button.

![switch_to_table_view](switch_to_table_view.png)

Now you can confirm that both the *DESCRIPTIO* and the *UPDATE_DAT* fields
have been updated for all the selected features.

![multi_edit_sucess](multi_edit_sucess.png)

Click **Next step** once you are done.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Until now, all the changes we have done are saved only in memory. Once
you are satisfied with all the changes you have made (which may include
changes to the features attributes and/or geometries), you must save
them permanently in the data source.

- In the **Digitizing toolbar**, click the **Save Layer Edits** button.

![save_layer_editis_button](save_layer_editis_button.png)

- Alternatively, in the **Attribute table** toolbar, click the
**Save Edits** button.

![save_edits_button](save_edits_button.png)

---

**NOTE:** Using the **Save** or **Save as** buttons in the **Project
toolbar**, <span style="color:red"> WILL NOT SAVE CHANGES TO THE
DATA</span>.

![warning_save_buttons](warning_save_buttons.png)

---

Click **Next step** once you are done.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
When you are done with editing the layer attributes (or geometries), you
should turn off editing for the layer.

- In the Attribute table toolbar, click the **Toggle edit mode**.

![toggle_editing_mode_off.png](toggle_editing_mode_off.png)

- Alternatively, you can use a similar button located in the *Digitizing
toolbar*, in QGIS's main window, or right-click the *Buildings* layer in the
*Layers Panel* and choose *Toggle Editing*.

![toggle_editing_alternatives_off.png](toggle_editing_alternatives_off.png)

**Note:** If you try to turn off editing before saving your changes, a
warning message will prevent you from losing any work by mistake. This
can also be used to revert any unsaved changes by clicking **Discard**.

![warning_save](warning_save.png)

This step ends the lesson, click **Finish**.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PROJCS["NAD83_North_Carolina_ftUS",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["standard_parallel_1",36.16666666666666],PARAMETER["standard_parallel_2",34.33333333333334],PARAMETER["latitude_of_origin",33.75],PARAMETER["central_meridian",-79],PARAMETER["false_easting",2000000],PARAMETER["false_northing",0],UNIT["Foot_US",0.30480060960121924]]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PROJCS["NAD83 / North Carolina (ftUS)",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["standard_parallel_1",36.16666666666666],PARAMETER["standard_parallel_2",34.33333333333334],PARAMETER["latitude_of_origin",33.75],PARAMETER["central_meridian",-79],PARAMETER["false_easting",2000000],PARAMETER["false_northing",0],UNIT["US survey foot",0.3048006096012192,AUTHORITY["EPSG","9003"]],AXIS["X",EAST],AXIS["Y",NORTH],AUTHORITY["EPSG","2264"]]
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UTF-8
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PROJCS["Lambert_Conformal_Conic",GEOGCS["GCS_GRS 1980(IUGG, 1980)",DATUM["D_unknown",SPHEROID["GRS80",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["standard_parallel_1",34.33333333333334],PARAMETER["standard_parallel_2",36.16666666666666],PARAMETER["latitude_of_origin",33.75],PARAMETER["central_meridian",-79],PARAMETER["false_easting",2000000.002616666],PARAMETER["false_northing",0],UNIT["Foot_US",0.30480060960121924]]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PROJCS["unnamed",GEOGCS["GRS 1980(IUGG, 1980)",DATUM["unknown",SPHEROID["GRS80",6378137,298.257222101],TOWGS84[0,0,0,0,0,0,0]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["standard_parallel_1",34.33333333333334],PARAMETER["standard_parallel_2",36.16666666666666],PARAMETER["latitude_of_origin",33.75],PARAMETER["central_meridian",-79],PARAMETER["false_easting",2000000.002616666],PARAMETER["false_northing",0],UNIT["Foot_US",0.3048006096012192]]
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UTF-8
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PROJCS["NAD83_North_Carolina_ftUS",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["standard_parallel_1",36.16666666666666],PARAMETER["standard_parallel_2",34.33333333333334],PARAMETER["latitude_of_origin",33.75],PARAMETER["central_meridian",-79],PARAMETER["false_easting",2000000],PARAMETER["false_northing",0],UNIT["Foot_US",0.30480060960121924]]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PROJCS["NAD83 / North Carolina (ftUS)",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["standard_parallel_1",36.16666666666666],PARAMETER["standard_parallel_2",34.33333333333334],PARAMETER["latitude_of_origin",33.75],PARAMETER["central_meridian",-79],PARAMETER["false_easting",2000000],PARAMETER["false_northing",0],UNIT["US survey foot",0.3048006096012192,AUTHORITY["EPSG","9003"]],AXIS["X",EAST],AXIS["Y",NORTH],AUTHORITY["EPSG","2264"]]
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UTF-8
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PROJCS["NAD83_North_Carolina_ftUS",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["standard_parallel_1",36.16666666666666],PARAMETER["standard_parallel_2",34.33333333333334],PARAMETER["latitude_of_origin",33.75],PARAMETER["central_meridian",-79],PARAMETER["false_easting",2000000],PARAMETER["false_northing",0],UNIT["Foot_US",0.30480060960121924]]
Loading

0 comments on commit 9b8cc30

Please sign in to comment.