4.3. Lesson: Clasificación

Labels are a good way to communicate information such as the names of individual places, but they can’t be used for everything. For example, let us say that someone wants to know what each landuse area is used for. Using labels, you would get this:

../../../_images/bad_landuse_labels.png

Esto dificulta la lectura el etiquetado del mapa e incluso sería abrumador si hay muchos usos diferentes del territorio en un mapa.

El objetivo de esta lección: Aprender como clasificar los datos vectoriales efectivamente.

4.3.1. basic Follow Along: Clasificación de Datos Nominales

  1. Open the Layer Properties dialog for the landuse layer

  2. Go to the Symbology tab

  3. Haga clic sobre la lista desplegable que dice Símbolo único y cambiarlo a Categorizado:

    ../../../_images/categorised_styles.png
  4. In the new panel, change the Value to landuse and the Color ramp to Random colors

  5. Clic el botón etiquetado Clasificar:

    ../../../_images/categorised_style_settings.png
  6. Click OK

    Verás algo como esto:

    ../../../_images/categorisation_result.png
  7. Click the arrow (or plus sign) next to landuse in the Layer list, you’ll see the categories explained:

    ../../../_images/categories_explained.png

    Now our landuse polygons are colored and are classified so that areas with the same land use are the same color.

  8. If you wish to, you can change the fill color for each landuse area by double-clicking the relevant color block in the Layers panel or in the Layer Properties dialog:

    ../../../_images/change_layer_color.png

Nota que hay una categoría vacía.

../../../_images/empty_category.png

This empty category is used to color any objects which do not have a landuse value defined or which have a NULL value. It can be useful to keep this empty category so that areas with a NULL value are still represented on the map. You may like to change the color to more obviously represent a blank or NULL value.

¡Recuerda guardar tu mapa ahora para no perder todos tus laboriosos cambios!

4.3.2. basic Try Yourself Más Clasificación

If you’re only following the basic-level content, use the knowledge you gained above to classify the buildings layer. Set the categorisation against the building field and use the Spectral color ramp.

Nota

Recuerda ampliar en un área urbana para ver los resultados.

4.3.3. moderate Follow Along: Clasificación por Razones

Hay cuatro tipos de clasificación: nominal, ordinal, de intervalos y relativa.

In nominal classification, the categories that objects are classified into are name-based; they have no order. For example: town names, district codes, etc. Symbols that are used for nominal data should not imply any order or magnitude.

  • For points, we can use symbols of different shape.

  • For polygons, we can use different types of hatching or different colours (avoid mixing light and dark colours).

  • For lines, we can use different dash patterns, different colours (avoid mixing light and dark colours) and different symbols along the lines.

In ordinal classification, the categories are arranged in a certain order. For example, world cities are given a rank depending on their importance for world trade, travel, culture, etc. Symbols that are used for ordinal data should imply order, but not magnitude.

  • For points, we can use symbols with light to dark colours.

  • For polygons, we can use graduated colours (light to dark).

  • For lines, we can use graduated colours (light to dark).

In interval classification, the numbers are on a scale with positive, negative and zero values. For example: height above/below sea level, temperature in degrees Celsius. Symbols that are used for ratio data should imply order and magnitude.

  • For points, we can use symbols with varying size (small to big).

  • For polygons, we can use graduated colours (light to dark) or add diagrams of varying size.

  • For lines, we can use thickness (thin to thick).

In ratio classification, the numbers are on a scale with only positive and zero values. For example: temperature above absolute zero (0 degrees Kelvin), distance from a point, the average amount of traffic on a given street per month, etc. Symbols that are used for ratio data should imply order and magnitude.

  • For points, we can use symbols with varying size (small to big).

  • For polygons, we can use graduated colours (light to dark) or add diagrams of varying size.

  • For lines, we can use thickness (thin to thick).

In the example above, we used nominal classification to color each record in the landuse layer based on its landuse attribute. Now we will use ratio classification to classify the records by area.

We are going to reclassify the layer, so existing classes will be lost if not saved.

  1. Guarde su simbología de uso de la tierra (si desea conservarla) haciendo click en el botón Save Style … en el menú desplegable Style.

  2. Close the Layer Properties dialog

  3. Open the Attributes Table for the landuse layer.

    We want to classify the landuse areas by size, but there is a problem: they don’t have a size field, so we’ll have to make one.

  4. Ingrese al modo de edición haciendo click en el botón toggleEditing

  5. Añada una nueva columna con el botón newAttribute

  6. Set up the dialog that appears like this:

    ../../../_images/add_area_column.png
  7. Click OK

    The new field will be added (at the far right of the table; you may need to scroll horizontally to see it). However, at the moment it is not populated, it just has a lot of NULL values.

    To solve this problem, we will need to calculate the areas.

  8. Abra la calculadora de campos en el botón calculateField

    You will get this dialog:

    ../../../_images/calculate_field_dialog.png
  9. Cambia los valores en la parte de arriba del cuadro de diálogo para que se vea como esto:

    ../../../_images/field_calculator_top.png
  10. In the Function List select Geometry ‣ $area:

    ../../../_images/geometry_area_select.png
  11. Double-click on it so that it appears in the Expression field

  12. Click OK

    Now your AREA field is populated with values (you may need to click the column header to refresh the data). Save the edits and close the attribute table.

    Nota

    These areas respect the project’s area unit settings, so they may be in square meters or square degrees.

  13. Open the Layer properties dialog’s Symbology tab for the landuse layer

  14. Change the classification style from Categorized to Graduated

  15. Change the Value to AREA

  16. Under Color ramp, choose the option Create New Color Ramp…:

    ../../../_images/area_gradient_select.png
  17. Choose Gradient (if it’s not selected already) and click OK. You will see this:

    ../../../_images/gradient_color_select.png

    Estarás usando esto para denotar áreas, con áreas pequeñas como Color 1 y áreas grandes como Color 2.

  18. Choose appropriate colors

    En el ejemplo, el resultado se ve así:

    ../../../_images/gradient_color_example.png
  19. Click OK

  20. You can save the colour ramp by selecting Save Color Ramp… under the Color ramp tab. Choose an appropriate name for the colour ramp and click Save. You will now be able to select the same colour ramp easily under All Color Ramps.

  21. Click Classify

    Now you will have something like this:

    ../../../_images/landuse_gradient_selected.png

    Deja todo lo demás como está.

  22. Click OK:

../../../_images/gradient_result_map.png

4.3.4. moderate Try Yourself Refinar la Clasificación

  • Cambia los valores de Modo y Clases hasta que obtengas una clasificación coherente.

Comprueba tus resultados

4.3.5. hard Follow Along: Clasificación basada en Reglas

Es común combinar múltiples criterios para una clasificación, pero desafortunadamente la clasificación normal solo tiene en cuenta un atributo. Ahí es donde la clasificación basada en reglas entra en juego.

  1. Open the Layer Properties dialog for the landuse layer

  2. Switch to the Symbology tab

  3. Switch the classification style to Rule-based

    QGIS will automatically show the rules that represent the current classification implemented for this layer. For example, after completing the exercise above, you may see something like this:

    ../../../_images/rule_based_classification.png
  4. Use the signMinus Remove selected rules button to remove all of the existing rules

  5. Click the signPlus Add rule button

  6. A new dialog then appears

  7. Click the expression button next to the Filter text area to open the Expression String Builder

  8. Enter the criterion "landuse" = 'residential' AND "name" <> 'Swellendam' (or "landuse" = 'residential' AND "name" != 'Swellendam'):

    ../../../_images/query_builder_example.png
  9. Click OK

  10. Choose a pale blue-grey Fill color and remove the border:

    ../../../_images/rule_style_result.png
  11. Click OK

  12. Add a new rule "landuse" <> 'residential' AND "AREA" >= 605000 and choose a mid-green color

  13. Add another new rule "name" = 'Swellendam' and assign it a darker grey-blue color in order to indicate the town’s importance in the region

  14. Click and drag this criterion to the top of the list

    These filters are exclusive, in that they collectively exclude some areas on the map (i.e. those which are smaller than 605000 (square meters), are not residential, and are not “Swellendam”). This means that the excluded polygons take the style of the default (no filter) category.

    Sabemos que los polígonos excluidos en nuestro mapa no pueden ser áreas residenciales, así que le daremos una categoría adecuada de verde pálido por defecto.

    Tu cuadro de diálogo ahora ha quedado así:

    ../../../_images/criterion_refined_list.png
  15. Apply this symbology

Tu mapa se parecerá a este:

../../../_images/rule_based_map_result.png

Ahora tienes un mapa con las áreas residenciales más destacadas Swellendam y otras áreas no residenciales coloreadas de acuerdo con su tamaño.

4.3.6. In Conclusion

La simbología nos permite representar los atributos de una capa de una forma sencilla de entender. También permite a los que visualicen el mapa entender el significado de las características, utilizando atributos relevantes que hemos escogido. Dependiendo del problema al que te enfrentes, aplicarás diferentes técnicas de clasificación para resolverlos.

4.3.7. What’s Next?

Ahora tenemos un bonito mapa, pero ¿Cómo obtendremos del QGIS un formato que se pueda imprimir o convertirlo en una imagen o PDF? ¡Ese es el tema de la siguiente lección!