Skip to content

Commit ce82240

Browse files
committed
Fix code-block and tab indentation
1 parent 844ab89 commit ce82240

File tree

14 files changed

+222
-175
lines changed

14 files changed

+222
-175
lines changed

docs/pyqgis_developer_cookbook/geometry.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ PyQGIS provides several options for creating a geometry:
8282
gLine = QgsGeometry.fromPolyline([QgsPoint(1, 1), QgsPoint(2, 2)])
8383
print(gLine)
8484
gPolygon = QgsGeometry.fromPolygonXY([[QgsPointXY(1, 1),
85-
QgsPointXY(2, 2), QgsPointXY(2, 1)]])
85+
QgsPointXY(2, 2), QgsPointXY(2, 1)]])
8686
print(gPolygon)
8787

8888
.. testoutput:: geometry

docs/pyqgis_developer_cookbook/plugins/plugins.rst

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ metadata.txt
100100
First, the Plugin Manager needs to retrieve some basic information about the
101101
plugin such as its name, description etc. This information is stored in :file:`metadata.txt`.
102102

103-
.. note::
104-
All metadata must be in UTF-8 encoding.
103+
.. note:: All metadata must be in UTF-8 encoding.
105104

106105
.. _plugin_metadata_table:
107106

@@ -127,15 +126,15 @@ homepage False a valid URL pointing to the homepage of your pl
127126
repository True a valid URL for the source code repository
128127
tracker False a valid URL for tickets and bug reports
129128
icon False a file name or a relative path (relative to
130-
the base folder of the plugin's compressed
131-
package) of a web friendly image (PNG, JPEG)
129+
the base folder of the plugin's compressed package)
130+
of a web friendly image (PNG, JPEG)
132131
category False one of ``Raster``, ``Vector``, ``Database``, ``Mesh`` and ``Web``
133-
plugin_dependencies False PIP-like comma separated list of other plugins to install, use
134-
plugin names coming from their metadata's name field
135-
server False boolean flag, :const:`True` or :const:`False`, determines if
136-
the plugin has a server interface
137-
hasProcessingProvider False boolean flag, :const:`True` or :const:`False`, determines if
138-
the plugin provides processing algorithms
132+
plugin_dependencies False PIP-like comma separated list of other plugins to install,
133+
use plugin names coming from their metadata's name field
134+
server False boolean flag, :const:`True` or :const:`False`,
135+
determines if the plugin has a server interface
136+
hasProcessingProvider False boolean flag, :const:`True` or :const:`False`,
137+
determines if the plugin provides processing algorithms
139138
===================== ======== =============================================================
140139

141140
By default, plugins are placed in the :menuselection:`Plugins` menu (we will see
@@ -469,9 +468,9 @@ languages you want.
469468

470469
.. warning::
471470

472-
Be sure to name the ``ts`` file like ``your_plugin_`` + ``language`` + ``.ts``
473-
otherwise the language loading will fail! Use the 2 letter shortcut for the
474-
language (**it** for Italian, **de** for German, etc...)
471+
Be sure to name the ``ts`` file like ``your_plugin_`` + ``language`` + ``.ts``
472+
otherwise the language loading will fail! Use the 2 letter shortcut for the
473+
language (**it** for Italian, **de** for German, etc...)
475474

476475
.ts file
477476
........
@@ -507,24 +506,24 @@ Alternatively you can use the makefile to extract messages from python code and
507506
Qt dialogs, if you created your plugin with Plugin Builder.
508507
At the beginning of the Makefile there is a LOCALES variable::
509508

510-
LOCALES = en
509+
LOCALES = en
511510

512511
Add the abbreviation of the language to this variable, for example for
513512
Hungarian language::
514513

515-
LOCALES = en hu
514+
LOCALES = en hu
516515

517516
Now you can generate or update the :file:`hu.ts` file (and the :file:`en.ts` too)
518517
from the sources by::
519518

520-
make transup
519+
make transup
521520

522521
After this, you have updated ``.ts`` file for all languages set in the LOCALES
523522
variable.
524523
Use **Qt Linguist** to translate the program messages.
525524
Finishing the translation the ``.qm`` files can be created by the transcompile::
526525

527-
make transcompile
526+
make transcompile
528527

529528
You have to distribute ``.ts`` files with your plugin.
530529

@@ -538,9 +537,9 @@ You should see your plugin in the correct language.
538537

539538
.. warning::
540539

541-
If you change something in your plugin (new UIs, new menu, etc..) you have to
542-
**generate again** the update version of both ``.ts`` and ``.qm`` file, so run
543-
again the command of above.
540+
If you change something in your plugin (new UIs, new menu, etc..) you have to
541+
**generate again** the update version of both ``.ts`` and ``.qm`` file, so run
542+
again the command of above.
544543

545544
Sharing your plugin
546545
===================
@@ -584,7 +583,7 @@ which can be handy for debugging purposes.
584583

585584
.. code-block:: python
586585
587-
my_plugin = qgis.utils.plugins['My Plugin']
586+
my_plugin = qgis.utils.plugins['My Plugin']
588587
589588
Log Messages
590589
------------
@@ -604,7 +603,7 @@ resources for the GUI, such as icons:
604603
605604
<RCC>
606605
<qresource prefix="/plugins/testplug" >
607-
<file>icon.png</file>
606+
<file>icon.png</file>
608607
</qresource>
609608
</RCC>
610609

docs/training_manual/database_concepts/queries.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ You can sort the results by the values of more than one column:
4949

5050
.. code-block:: sql
5151
52-
select name, house_no from people order by name, house_no;
52+
select name, house_no from people order by name, house_no;
5353
5454
Result:
5555

docs/training_manual/processing/no_data.rst

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,65 +28,100 @@ To start with, we will change the units of the DEM from meters to feet. The form
2828

2929
::
3030

31-
h' = h * 3.28084
31+
h' = h * 3.28084
3232

3333
Select the DEM in the layers field and type ``a * 3.28084`` in the formula field.
3434

3535
.. warning:: For non English users: use always ".", not ",".
3636

37-
Click *Run* to run the algorithm. You will get a layer that has the same appearance of the input layer, but with different values. The input layer that we used has valid values in all its cells, so the last parameter has no effect at all.
37+
Click *Run* to run the algorithm. You will get a layer that has the same appearance of the input layer, but with different values.
38+
The input layer that we used has valid values in all its cells, so the last parameter has no effect at all.
3839

39-
Let's now perform another calculation, this time on the *accflow* layer. This layer contains values of accumulated flow, a hydrological parameter. It contains those values only within the area of a given watershed, with no--data values outside of it. As you can see, the rendering is not very informative, due to the way values are distributed. Using the logarithm of that flow accumulation will yield a much more informative representation. We can calculate that using the raster calculator.
40+
Let's now perform another calculation, this time on the *accflow* layer.
41+
This layer contains values of accumulated flow, a hydrological parameter.
42+
It contains those values only within the area of a given watershed, with no--data values outside of it.
43+
As you can see, the rendering is not very informative, due to the way values are distributed.
44+
Using the logarithm of that flow accumulation will yield a much more informative representation.
45+
We can calculate that using the raster calculator.
4046

41-
Open the algorithm dialog again, select the *accflow* layer as the only input layer, and enter the following formula: ``log(a)``.
47+
Open the algorithm dialog again, select the *accflow* layer as the only input layer,
48+
and enter the following formula: ``log(a)``.
4249

4350
Here is the layer that you will get.
4451

4552
.. figure:: img/no_data/log.png
4653

47-
If you select the *Identify* tool to know the value of a layer at a given point, select the layer that we have just created, and click on a point outside of the basin, you will see that it contains a no--data value.
54+
If you select the *Identify* tool to know the value of a layer at a given point,
55+
select the layer that we have just created, and click on a point outside of the basin,
56+
you will see that it contains a no--data value.
4857

4958
.. figure:: img/no_data/identify.png
5059

51-
For the next exercise we are going to use two layers instead of one, and we are going to get a DEM with valid elevation values only within the basin defined in the second layer. Open the calculator dialog and select both layers of the project in the input layers field. Enter the following formula in the corresponding field:
60+
For the next exercise we are going to use two layers instead of one,
61+
and we are going to get a DEM with valid elevation values only within the basin defined in the second layer.
62+
Open the calculator dialog and select both layers of the project in the input layers field.
63+
Enter the following formula in the corresponding field:
5264

5365
::
5466

55-
a/a * b
67+
a/a * b
5668

57-
``a`` refers to the accumulated flow layer (since it is the first one to appear in the list) and ``b`` refers to the DEM. What we are doing in the first part of the formula here is to divide the accumulated flow layer by itself, which will result in a value of 1 inside the basin, and a no--data value outside. Then we multiply by the DEM, to get the elevation value in those cells inside the basin (``DEM * 1 = DEM``) and the no--data value outside (``DEM * no_data = no_data``)
69+
``a`` refers to the accumulated flow layer (since it is the first one to appear in the list) and ``b`` refers to the DEM.
70+
What we are doing in the first part of the formula here is to divide the accumulated flow layer by itself,
71+
which will result in a value of 1 inside the basin, and a no--data value outside.
72+
Then we multiply by the DEM, to get the elevation value in those cells inside the basin (``DEM * 1 = DEM``)
73+
and the no--data value outside (``DEM * no_data = no_data``)
5874

5975
Here is the resulting layer.
6076

6177
.. figure:: img/no_data/masked.png
6278

6379

64-
This technique is used frequently to *mask* values in a raster layer, and is useful whenever you want to perform calculations for a region other that the arbitrary rectangular region that is used by raster layer. For instance, an elevation histogram of a raster layer doesn't have much meaning. If it is instead computed using only values corresponding to a basin (as in he case above), the result that we obtain is a meaningful one that actually gives information about the configuration of the basin.
80+
This technique is used frequently to *mask* values in a raster layer,
81+
and is useful whenever you want to perform calculations for a region
82+
other that the arbitrary rectangular region that is used by raster layer.
83+
For instance, an elevation histogram of a raster layer doesn't have much meaning.
84+
If it is instead computed using only values corresponding to a basin (as in he case above),
85+
the result that we obtain is a meaningful one that actually gives information about the configuration of the basin.
6586

66-
There are other interesting things about this algorithm that we have just run, apart from the no--data values and how they are handled. If you have a look at the extents of the layers that we have multiplied (you can do it double--clicking on their names of the layer in the table of contents and looking at their properties), you will see that they are not the same, since the extent covered by the flow accumulation layer is smaller that the extent of the full DEM.
87+
There are other interesting things about this algorithm that we have just run,
88+
apart from the no--data values and how they are handled.
89+
If you have a look at the extents of the layers that we have multiplied
90+
(you can do it double-clicking on the names of the layer in the table of contents and looking at their properties),
91+
you will see that they are not the same, since the extent covered by the flow accumulation layer is smaller that the extent of the full DEM.
6792

68-
That means that those layers do not match, and that they cannot be multiplied directly without homogenizing those sizes and extents by resampling one or both layers. However, we did not do anything. QGIS takes care of this situation and automatically resamples input layers when needed. The output extent is the minimum covering extent calculated from the input layers, and the minimum cell size of their cellsizes.
93+
That means that those layers do not match, and that they cannot be multiplied directly
94+
without homogenizing those sizes and extents by resampling one or both layers.
95+
However, we did not do anything. QGIS takes care of this situation and automatically resamples input layers when needed.
96+
The output extent is the minimum covering extent calculated from the input layers, and the minimum cell size of their cellsizes.
6997

70-
In this case (and in most cases), this produces the desired results, but you should always be aware of the additional operations that are taking place, since they might affect the result. In cases when this behaviour might not be the desired, manual resampling should be applied in advance. In later chapters, we will see more about the behaviour of algorithms when using multiple raster layers.
98+
In this case (and in most cases), this produces the desired results,
99+
but you should always be aware of the additional operations that are taking place, since they might affect the result.
100+
In cases when this behaviour might not be the desired, manual resampling should be applied in advance.
101+
In later chapters, we will see more about the behaviour of algorithms when using multiple raster layers.
71102

72103

73-
Let's finish this lesson with another masking exercise. We are going to calculate the slope in all areas with an elevation between 1000 and 1500 meters.
104+
Let's finish this lesson with another masking exercise.
105+
We are going to calculate the slope in all areas with an elevation between 1000 and 1500 meters.
74106

75107
In this case, we do not have a layer to use as a mask, but we can create it using the calculator.
76108

77109
Run the calculator using the DEM as only input layer and the following formula
78110

79111
::
80112

81-
ifelse(abs(a-1250) < 250, 1, 0/0)
113+
ifelse(abs(a-1250) < 250, 1, 0/0)
82114

83-
As you can see, we can use the calculator not only to do simple algebraic operations, but also to run more complex calculation involving conditional sentences, like the one above.
115+
As you can see, we can use the calculator not only to do simple algebraic operations,
116+
but also to run more complex calculation involving conditional sentences, like the one above.
84117

85118
The result has a value of 1 inside the range we want to work with, and no-data in cells outside of it.
86119

87120
.. figure:: img/no_data/elevation_mask.png
88121

89-
The no-data value comes from the 0/0 expression. Since that is an undetermined value, SAGA will add a NaN (Not a Number) value, which is actually handled as a no-data value. With this little trick you can set a no-data value without needing to know what the no--data value of the cell is.
122+
The no-data value comes from the 0/0 expression. Since that is an undetermined value,
123+
SAGA will add a NaN (Not a Number) value, which is actually handled as a no-data value.
124+
With this little trick you can set a no-data value without needing to know what the no--data value of the cell is.
90125

91126
Now you just have to multiply it by the slope layer included in the project, and you will get the desired result.
92127

docs/training_manual/processing/vector_calculator.rst

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,58 @@ Vector calculator
22
============================================================
33

44

5-
.. note:: In this lesson we will see how to add new attributes to a vector layer based on a mathematical expression, using the vector calculator.
5+
.. note:: In this lesson we will see how to add new attributes to a vector layer
6+
based on a mathematical expression, using the vector calculator.
67

7-
We already know how to use the raster calculator to create new raster layers using mathematical expressions. A similar algorithm is available for vector layers, and generates a new layer with the same attributes of the input layer, plus an additional one with the result of the expression entered. The algorithm is called :guilabel:`Field calculator` and has the following parameters dialog.
8+
We already know how to use the raster calculator to create new raster layers using mathematical expressions.
9+
A similar algorithm is available for vector layers, and generates a new layer with the same attributes of the input layer,
10+
plus an additional one with the result of the expression entered.
11+
The algorithm is called :guilabel:`Field calculator` and has the following parameters dialog.
812

913
.. figure:: img/vector_calculator/field_calculator.png
1014

1115
.. note:: In newer versions of Processing the interface has changed considerably, it's more powerful and easier to use.
1216

1317
Here are a few examples of using that algorithm.
1418

15-
First, let's calculate the population density of white people in each polygon, which represents a census. We have two fields in the attributes table that we can use for that, namely ``WHITE`` and ``SHAPE_AREA``. We just have to divide them and multiply by one million (to have density per square km), so we can use the following formula in the corresponding field
19+
First, let's calculate the population density of white people in each polygon, which represents a census.
20+
We have two fields in the attributes table that we can use for that, namely ``WHITE`` and ``SHAPE_AREA``.
21+
We just have to divide them and multiply by one million (to have density per square km),
22+
so we can use the following formula in the corresponding field::
1623

17-
::
18-
19-
( "WHITE" / "SHAPE_AREA" ) * 1000000
24+
( "WHITE" / "SHAPE_AREA" ) * 1000000
2025

2126
The parameters dialog should be filled as shown below.
2227

2328
.. figure:: img/vector_calculator/density.png
2429

25-
This will generate a new field named ``WHITE_DENS``
26-
27-
Now let's calculate the ratio between the ``MALES`` and ``FEMALES`` fields to create a new one that indicates if male population is numerically predominant over female population.
30+
This will generate a new field named ``WHITE_DENS``.
2831

29-
Enter the following formula
32+
Now let's calculate the ratio between the ``MALES`` and ``FEMALES`` fields to create a new one
33+
that indicates if male population is numerically predominant over female population.
3034

31-
::
35+
Enter the following formula::
3236

33-
"MALES" / "FEMALES"
37+
"MALES" / "FEMALES"
3438

3539
This time the parameters window should look like this before pressing the :guilabel:`OK` button.
3640

3741
.. figure:: img/vector_calculator/ratio.png
3842

3943

40-
In earlier version, since both fields are of type integer, the result would be truncated to an integer. In this case the formula should be: ``1.0 * "MALES" / "FEMALES"``, to indicate that we want floating point number a result.
44+
In earlier version, since both fields are of type integer, the result would be truncated to an integer.
45+
In this case the formula should be: ``1.0 * "MALES" / "FEMALES"``, to indicate that we want floating point number a result.
4146

42-
We can use conditional functions to have a new field with ``male`` or ``female`` text strings instead of those ratio value, using the following formula::
47+
We can use conditional functions to have a new field with ``male`` or ``female`` text strings
48+
instead of those ratio value, using the following formula::
4349

44-
CASE WHEN "MALES" > "FEMALES" THEN 'male' ELSE 'female' END
50+
CASE WHEN "MALES" > "FEMALES" THEN 'male' ELSE 'female' END
4551

4652
The parameters window should look like this.
4753

4854
.. figure:: img/vector_calculator/predominance.png
4955

50-
A python field calculator is available in the :guilabel:`Advanced Python field calculator`, which will not be detailed here
56+
A python field calculator is available in the :guilabel:`Advanced Python field calculator`,
57+
which will not be detailed here.
5158

5259
.. figure:: img/vector_calculator/advanced.png

0 commit comments

Comments
 (0)