
Habitat Suitability Analysis Using a Grid
What you'll learn
- Analysis methods using a grid (mesh)
- How to aggregate information into a layer's attributes
- How to analyze suitable habitats for organisms
Recommended for
- Anyone who wants to analyze habitats of organisms with GIS
- Anyone who wants to learn the basics of grid analysis
Introduction
In ecology and conservation, analyzing suitable habitats is essential for protecting organisms. There are many ways to do it, but GIS can analyze suitable habitats based on geographic conditions, which makes it faster to identify suitable areas.
This article introduces a method for analyzing habitat suitability for organisms in QGIS.

Habitat suitability analysis method
The method in this article divides the target area into a grid (mesh) and tallies environmental conditions, such as slope and vegetation, for each grid cell. It then scores each cell: 1 point if one condition is met, 2 points if two are met, and so on. The higher a cell's total score, the more suitable the area is judged to be.

This article analyzes habitat suitability for an organism that prefers the following environment. For your own target organism, compile information on its preferred environment from the literature.
- Prefers high elevation
- Prefers forested areas
- Prefers environments near water
To extract these conditions with GIS, this article uses the Fundamental Geospatial Data elevation model (Geospatial Information Authority of Japan, GSI), and the Forest Area Data and River Data from National Land Numerical Information. Prepare the data that fits your target species and conditions.

Habitat suitability analysis steps
Create the grid
First, create the grid data for the analysis. Create the grid over the survey area for the habitat suitability analysis.
To create the grid, run Vector → Research Tools → Create grid.
Use these settings:
-
Grid type: select Rectangle (Polygon).
-
Grid extent: specify the area where you want to create the grid. Click the ▼ button on the right to specify the extent of a layer or the area currently shown in the map canvas, or to specify an area on the map.
-
Horizontal spacing: specify the east-west size of one cell. This example uses 50 meters.
A smaller grid size gives a more detailed analysis but can take longer to process. Choose the grid size based on the target organism's range of movement and the size of the analysis area.
-
Vertical spacing: specify the north-south size of one cell. This example uses 50 meters.
-
Grid: specify where to save the data.

When you run the algorithm, QGIS creates grid data with the specified extent and size.

Condition 1: prefers high elevation
The first condition is a preference for high elevation. Aggregate the elevation values for each grid cell, and score 1 point if the mean is 150 m or higher and 0 points otherwise.
To aggregate raster values for each grid cell, open the Processing Toolbox and run Raster analysis → Zonal statistics.
- Input layer: the grid layer
- Raster layer: the elevation layer (the raster with the values to aggregate)
- Statistics to calculate: select Mean
- Zonal Statistics: specify where to save the data and the file name

When you run the algorithm, QGIS outputs a layer. In its attribute table, the _mean column holds the mean values.

Next, classify each cell by whether this mean is below 150 or 150 or higher.
Open the Field Calculator from the attribute table.
- Select Create a new field.
- This example uses
demfor the field name, Integer (32 bit) for the type, and10for the length. - Expression:
if( "_mean" >= 150,1,0)

After you apply these settings and click OK, a dem column is added to the attribute table. It holds 1 where _mean is 150 or higher and 0 otherwise. The scores for the remaining conditions are added to this layer's attributes in the same way.

Condition 2: prefers forested areas
For the second condition, “prefers forested areas,” a grid cell scores 1 if a forest area lies within it and 0 if it does not.

To check whether each grid cell contains a forest feature, use Select by location.
- Select features from: the grid layer
- Where the features (geometric predicate): select intersect
- By comparing to the features from: the forest area layer
- Modify current selection by: select creating new selection

The grid cells that overlap forest areas are selected and highlighted in yellow.

With the cells still selected, open the attribute table, and then open the Field Calculator.
- Clear Only update selected features.
- Select Create a new field, and specify the field name, type, and length.
- Enter
if( is_selected( ), 1, 0)as the expression.

The function is_selected( ) returns TRUE when a feature is selected. When you run the Field Calculator, the selected grid cells (those that overlap forest areas) get 1, and the other cells get 0.

Condition 3: prefers areas near water
For the third condition, “prefers areas near water,” a grid cell scores 1 if it is within 100 m of a river and 0 otherwise.

Following the same approach as before, select the grid cells within 100 m of a river with Select within distance.
- Select features from: the grid layer
- By comparing to the features from: the river layer
- Where the features are within: 100 meters
- Modify current selection by: select creating new selection

The grid cells within 100 m of a river are selected and highlighted in yellow.

With the cells still selected, open the attribute table, and then open the Field Calculator.
- Clear Only update selected features.
- Select Create a new field, and specify the field name, type, and length.
- Enter
if( is_selected( ), 1, 0)as the expression.

When you run the Field Calculator, the selected grid cells (those within 100 m of a river) get 1, and the other cells get 0.

Calculate the total score
Add up the scores of the three conditions to get the habitat suitability result.
Open the Field Calculator from the attribute table of the grid layer.
- Select Create a new field, and specify the field name, type, and length.
- Build an expression that adds up the condition scores calculated above. Enter
“dem” + “forest” + “river”.

When you run the Field Calculator, QGIS adds a column holding the sum of the three scores.

Finally, color the grid cells by total score. Areas with higher scores are more suitable habitat.

Conclusion
This article introduced a method for estimating suitable habitat for animals, plants, and other organisms with GIS.
The method applies not only to selecting suitable habitat but also to a wide range of other analyses, such as finding suitable sites for wind and solar power generation, assessing disaster risk, and planning new store locations.
This example used three conditions: elevation of 150 m or higher, presence of a forest area, and a distance of 100 m or less from a river. You can also try other environmental conditions, such as “1 point if a certain vegetation type covers at least ○ ha of the cell,” or “1 point if the slope angle is between ○ and ○ degrees, and 2 points if it is ○ degrees or more.”


QGIS LAB is a comprehensive information hub for QGIS, the open-source GIS software. Under the concept of “Geospatial for Greater Good,” we share the knowledge and skills to open up the world through location data.


