# Regression¶

This section will demonstrate a case of image regression using the test dataset. We will regress the sub-pixel fractions of impervious, vegetation, soil and water, derived from a high resolution land cover polygon vector dataset, against the spectral signature of an EnMAP image. So in this case we are performing a multi target regression (more than one response variable), but mind that single target regression works in the same way.

1. In a preliminary step we are going to convert the polygon dataset to a fraction raster dataset which fits the resolution of the EnMAP raster. This raster will be the regression target, where each band corresponds to the fraction of a landcover class from the polygon dataset inside an EnMAP pixel (so percentage of impervious, vegetation, soil and water, respectively).

In the processing toolbox go to EnMAP-Box ‣ Create Raster ‣ Fraction from Vector. Enter the following settings:

• Pixel Grid: enmap_berlin.bsq
• Vector: landcover_berlin_polygon.shp
• Class id attribute: level_1_id
• Minimal overall coverage: 0.7
• Oversampling factor: 5
• Output Fraction: Click on and specify an output file path.

Click Run.

2. Now that we have a regression target raster we are going to fit a regression model. In the processing toolbox go to EnMAP-Box ‣ Regression ‣ Fit RandomForestRegressor.

• Select enmap_berlin.bsq as Raster and under Regression specify the output raster from step 1 (the regression target).
• Leave the rest at default and under Output Regressor specify an output file path and click Run
3. In the next step we will apply the regression to the image. Go to EnMAP-Box ‣ Regression ‣ Predict Regression. Select enmap_berlin.bsq as input Raster and under Regressor click and select the output .pkl file from the Fit RandomForestRegressor algorithm. Specify an output path (Output Regression) and click Run.