4.3. Lesson: 범주화

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

라벨을 읽기 어려울 뿐만 아니라 맵 상에 수많은 토지이용구역이 있을 경우 혼잡하기까지 합니다.

이 강의의 목표: 벡터 데이터를 효율적으로 범주화하는 방법 배우기.

4.3.1. basic Follow Along: 명칭 데이터 범주화

  1. Open the Layer Properties dialog for the landuse layer

  2. Go to the Symbology tab

  3. Single Symbol 이라는 드롭다운 메뉴를 클릭해서, Categorized 로 변경하십시오.

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

  5. Classify 버튼을 클릭하십시오.

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

    결과는 다음과 같습니다.

    ../../../_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

비어 있는 카테고리가 하나 있는 게 보이십니까?

../../../_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.

여러분이 힘들게 바꾼 변경 사항을 잃지 않도록 지금 맵을 저장하세요!

4.3.2. basic Try Yourself 고급 범주화

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.

참고

결과를 보려면 도심 지역으로 줌인해야 합니다.

4.3.3. moderate Follow Along: 비율 범주화

범주화에는 명칭, 순서, 간격, 그리고 비율, 네 가지 유형이 있습니다.

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. Save your landuse symbology (if you want to keep it) by clicking on the Save Style … button in the Style drop-down menu.

  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. Enter edit mode by clicking the toggleEditing button

  5. Add a new column with the newAttribute button

  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. Open the field calculator with the calculateField button

    You will get this dialog:

    ../../../_images/calculate_field_dialog.png
  9. 대화 창의 맨 위에 있는 값을 다음과 같이 변경합니다.

    ../../../_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.

    참고

    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

    이 창을 이용해서, 적은 면적을 Color 1 로, 큰 면적을 Color 2 로 나타낼 것입니다.

  18. Choose appropriate colors

    이 예제에서는 다음과 비슷한 결과가 나옵니다.

    ../../../_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

    다른 항목은 그대로 놔둡니다.

  22. Click OK:

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

4.3.4. moderate Try Yourself 범주화 개선

  • 여러분의 범주화를 이해하기 쉽도록 ModeClasses 의 값을 변경해보십시오.

결과 확인

4.3.5. hard Follow Along: 규칙 기반 범주화

범주화에 복수의 기준을 결합하는 것이 유용할 경우가 많지만, 아쉽게도 일반 범주화에서는 단일 기준만 적용됩니다. 이런 경우 규칙 기반 범주화를 쓸 수 있습니다.

  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.

    맵 상에서 제외된 폴리곤들은 주거지역이 아니므로 기본 카테고리에 어울리는 엷은 청회색을 할당하도록 합시다.

    이제 사용자의 대화 창이 이렇게 보여야 합니다.

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

사용자 맵이 다음과 비슷하게 보일 것입니다.

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

이제 Swellendam 이 가장 두드러진 주거지역으로 나타나고 다른 비주거지역은 면적에 따라 다른 색상을 보여주는 맵이 되었습니다.

4.3.6. In Conclusion

심볼을 이용하면 레이어의 속성들을 읽기 쉬운 방법으로 나타낼 수 있습니다. 우리가 선택한 연관 속성을 이용해서 피처의 중요성을 이해하도록 만들 수 있습니다. 여러분이 당면한 문제가 무엇이냐에 따라 다른 범주화 기술을 적용해서 문제를 해결하십시오.

4.3.7. What’s Next?

이제 멋진 맵을 만들었습니다만, 이것을 어떻게 QGIS에서 분리시켜 인쇄할 수 있는 파일 형식이나 이미지 또는 PDF로 만들 수 있을까요? 이것이 다음 강의의 주제입니다!