Skip to contents

The classifiers are trained on one set of landscapes and applied to another. Before applying a model, check that training and application landscapes use comparable raster geometry and land-cover coding. This guide explains how the metric- and pixel-based workflows handle geometry differences and what each workflow requires.

Aspects of landscape geometry

Training and application landscapes can differ in four ways:

Geometry aspect Meaning Example
Extent width and height of the area covered train on 100 × 100 cells, apply to 200 × 200 cells at the same resolution
Resolution ground size represented by one cell train on 1 m cells, apply to 30 m cells
Aspect ratio ratio of columns to rows train on 100 × 100 cells, apply to 200 × 80 cells
Shape rectangular or irregular study-area outline apply to a clipped catchment boundary

A raster grid is always rectangular, so an irregular shape is usually represented by NA cells outside its boundary.

How the workflows handle geometry differences

The metric and pixel workflows respond differently to geometry differences. The metric workflow is particularly sensitive because many metric values depend on geometry. The table below shows how the two workflows handle geometry differences between training and application data if they are detected.

Geometry aspect Metric-based Pixel-based
Extent Applies the model but warns about substantial differences Resizes row and column counts to the training grid, but does not compare physical extent
Resolution Applies the model but warns about differences in cell resolution Does not compare training and application cell resolution (only row and column counts)
Aspect ratio Applies the model and warns about substantial differences Warns when resizing stretches the pattern anisotropically
Shape Excludes missing cells from the analysed area and does not compare shapes directly Stops with an error if any cell is missing

Metric-based workflow

apply_metric_model() calculates the required metrics for the application landscapes as they are supplied. It does not resample or correct them if their geometry differs from the training data. calculate_metrics() records the geometry of each training landscape, and train_metric_model() stores a summary. apply_metric_model() compares the application geometry with this summary and warns about substantial differences in spatial extent, resolution, or aspect ratio. train_metric_model() also warns when the training landscapes differ in dimensions or resolution.

Geometry affects some metrics more than others. Raw area and count metrics, and some shape metrics, can change strongly with extent and resolution, even if the patterns look similar.

If the selected metrics are sensitive to geometry, the classifier may conflate geometry with the pattern. If you encounter geometry warnings, check whether the selected metrics are appropriate for the differences in your data.

Pixel-based workflow

train_pixel_model() requires one categorical raster layer per landscape. All training landscapes must have the same number of rows and columns and contain no NA cells. Cell resolution is not considered by the pixel-workflow.

If training and application landscapes differ in their row/column number, apply_pixel_model() resamples the application rasters to the training dimensions with nearest-neighbour resampling. The function warns when a different aspect ratio would stretch the pattern and stops if the raster contains any NA cells.

During model training each land-cover code is fixed onto one input channel. Therefore, application landscapes can only contain land-cover codes that were also seen during model training.

Prepare the data

Below you can find some guidelines on preparing and matching training and application data

  • Use the same numeric whole-number code for the same land-cover types in training and application data.
  • Use matching cell resolution and spatial extent in training and application data. This is especially important for the metric workflow because it is particularly sensitive to such differences. Artificial landscapes created by patternscaper have resolution 1 and can easily be created with the desired extent.
  • If you have enough data, test the model on labelled landscapes with the geometry expected in the application data before classifying unlabelled landscapes. This helps you to assess the model performance.
  • Pixel models reject landscapes with NA cells. An irregular study area therefore cannot be classified directly as one pixel landscape.

Next steps

Continue with the guide for your classification workflow: