Conditional field calculator
From AWF-Wiki
(Difference between revisions)
(One intermediate revision by one user not shown) | |||
Line 1: | Line 1: | ||
− | We would like to use the European Urban Atlas as an information vector layer to automatically extract reference data for an actual land cover classification. The original Urban Atlas classifcation scheme has 37 classes. We need to | + | We would like to use the European Urban Atlas as an information vector layer to automatically extract reference data for an actual land cover classification. The original Urban Atlas classifcation scheme has 37 classes. We need to define some strata for sampling training data for land cover classification. |
# Click {{button|text=Add vector layer}} [[Image:QGIS_2.0_addvect.png|20px]] and select file ''geodata/vector/Subset-Goe_DE021L1_GOTTINGEN_UA2012_UTM32N.shp''. | # Click {{button|text=Add vector layer}} [[Image:QGIS_2.0_addvect.png|20px]] and select file ''geodata/vector/Subset-Goe_DE021L1_GOTTINGEN_UA2012_UTM32N.shp''. | ||
+ | # This file still contains geometry errors (ring self-intersections). Check with {{mitem|text=Vector --> Geometry Tools --> Check Validity}} Field calculator}} | ||
+ | # Repair the vector file: {{mitem|text=Processing Tools --> Vector geometry --> Fix geometries}}. Save the output fixed geometry file as Geppackage with the extension '''*.gpkg'''. | ||
# In the processing toolbar, type {{typed|text=Field calculator}} to browse for the {{mitem|text=QGIS --> Vector Table Tools --> Field calculator}} and open it. | # In the processing toolbar, type {{typed|text=Field calculator}} to browse for the {{mitem|text=QGIS --> Vector Table Tools --> Field calculator}} and open it. | ||
− | # Define name and path of a new vector Output layer. Tick '''Create new field''', specify the Output field name {{typed|text= | + | # Define name and path of a new vector Output layer. Tick '''Create new field''', specify the Output field name {{typed|text=stratum}} as '''Whole number (integer)'''. |
− | # Formulate 5 conditional operations creating a new vector file adding a new column named ''' | + | # Formulate 5 conditional operations creating a new vector file adding a new column named '''stratum''': |
<pre>CASE | <pre>CASE | ||
WHEN "CODE2012" = 11100 THEN 1 | WHEN "CODE2012" = 11100 THEN 1 |
Latest revision as of 16:29, 16 December 2020
We would like to use the European Urban Atlas as an information vector layer to automatically extract reference data for an actual land cover classification. The original Urban Atlas classifcation scheme has 37 classes. We need to define some strata for sampling training data for land cover classification.
- Click Add vector layer and select file geodata/vector/Subset-Goe_DE021L1_GOTTINGEN_UA2012_UTM32N.shp.
- This file still contains geometry errors (ring self-intersections). Check with Vector --> Geometry Tools --> Check Validity Field calculator}}
- Repair the vector file: Processing Tools --> Vector geometry --> Fix geometries. Save the output fixed geometry file as Geppackage with the extension *.gpkg.
- In the processing toolbar, type Field calculator to browse for the QGIS --> Vector Table Tools --> Field calculator and open it.
- Define name and path of a new vector Output layer. Tick Create new field, specify the Output field name stratum as Whole number (integer).
- Formulate 5 conditional operations creating a new vector file adding a new column named stratum:
CASE WHEN "CODE2012" = 11100 THEN 1 WHEN "CODE2012" = 21000 THEN 2 WHEN "CODE2012" = 23000 THEN 3 WHEN "CODE2012" = 31000 THEN 4 WHEN "CODE2012" = 50000 THEN 5 END