Leonardo Porto Nazareth
- Creating and configuring a new project in QGIS
- Project settings
- Step One - Create Base Layers
- Step Two - Delimitation of Subareas
- Step Three - Sanitation System Evaluation
- Adjustments to the Subareas
The step-by-step instructions for using the scripts developed are described below.
The first step in using the scripts you have created is to create a new project in QGIS.
-
Open QGIS.
-
Click on the “New Project” button in the top left-hand corner of the window.
-
Choose the directory where the new project will be saved and the name of the project.
-
Add the project layers, for example a vector layer with the administrative regions, or a raster layer with the available satellite image.
Note: we recommend using the QGIS plugin “QuickMapServices” to add satellite image base layers or OpenStreetMaps.
Note2: you can download the project and base files used in the research case study (city of Boca Chica, Dominican Republic) from the LINK However, the water consumption data of the polygons has been altered for privacy reasons
In order for the scripts to work correctly, some settings must be made in the project:
- The project must be configured with a Coordinate Reference System (CRS) that uses the mercator projection and the metos unit. To do this, after creating the project and adding the vector layers, the user must click on the button in the bottom right-hand corner of the screen, which indicates the project's current EPSG code, and in the window displayed select the CRS of the location they are working in.
IMPORTANT: The Styles folder downloaded with the scripts must be saved in the same directory as the QGIS project. For example, if the Exemplo_sanitation.qgz project is saved in the “C:/user/QGIS_project” directory, the Styles folder must be saved in the same location.
Note: This must be done for every new project in which the user wants to use the scripts developed.
The Create Base Layers script is designed to assist planners in defining project areas and ensuring that all necessary data is included. It facilitates the process of creating and organizing essential spatial information for sanitation planning.
The Create Base Layers script generates standardized layers essential for sanitation planning:
- Area of Interest (AOI) – Mandatory layer
- Existing Sanitation Systems – Auxiliary layer
- Water Availability – Auxiliary layer
- Administrative Boundaries – Auxiliary layer
Additionally, under the Advanced Parameters, the script can optionally generate a Population Density Grid.
-
Open the Processing Toolbox Panel and double-click on 01 Create Base Layers under the Scripts > Sanitation Planning section.
-
In the Processing Algorithm Window, select the checkboxes for the layers you wish to create.
-
Ensure a Mercator CRS (meter-based) is selected (if not, manually select one).
-
Choose the format and directory for the output layers. If no directory is specified, the script will generate temporary layers.
Note: Temporary layers will be lost when QGIS is closed, even if the project is saved.
-
Click Run to execute the script.
-
To generate a population density grid, expand the Advanced Parameters by clicking the arrow beside it.
-
Specify the extent for the grid creation (e.g., the current map canvas extent).
-
Choose either a Raster or Vector layer that contains population data. For Vector layers, select the field that stores the population data.
-
Provide additional information such as:
- The year of the population dataset,
- The type and size of the grid to be created,
- The annual growth rate, and
- The target year for the population projection.
Note: The population will be projected to the target year using a linear growth model, and the population density will be calculated accordingly.
To delimit the areas, follow these steps:
-
Select the layer you want to use for delimitation. For example, to outline the project area, select the AOI (Area of Interest) layer.
-
Toggle the selected layer to Edit Mode.
-
Use the Drawing Features tool in QGIS to begin delineating the area of interest for the project.
-
Once you have finished drawing, right-click to complete the shape, and then click OK in the form dialog.
-
Depending on the layer in use, certain mandatory information may need to be entered before clicking OK in the form window.
Note: To edit, delete, or modify the attributes of the polygons, use QGIS’ native tools, such as Delete Features, Vertex Tool, or Attribute table.
Subareas are the smallest polygons formed by the intersection of the layers created in the previous step.
The delimitation of the subareas is not done manually. Instead, the algorithm 02 - Delimitation of Subareas automatically generates them by intersecting all the parent layers defined in Step 1. The subareas are consolidated into a single layer, with all attributes combined and organized accordingly.
-
Double-click on 02 - Delimitation of Subareas under the Scripts > Sanitation Planning section.
-
Select the layers with the delimited areas created in Step One.
-
Define the minimum size for the subareas. This helps to avoid generating small polygons in the gaps between previously delimited areas.
-
Choose the name and directory for the Subarea Layer.
-
Click Run to execute the algorithm.
- It is also possible to generate a population density grid in this script, just like in step 1, but it automatically clip the grids at the AOI boundaries.
Note: You can modify the attributes of the subareas at any time. This can be done using the attribute table or the Identify tool by clicking on the polygon and editing it via the feature form.
This process creates a Subarea Sanitation Suggestion layer, by calculating indicators and the most suitable sanitation system for each subarea.
The population dataset is a mandatory input (raster or vector format), while streets, paths, and building footprint layers are optional data.
Required Input Parameters:
- Population Dataset Year: Year of the population dataset
- Low-Density Population Limit: Upper limit for low population density (inhab./ha)
- Medium-Density Population Limit: Upper limit for medium population density (inhab./ha)
- Annual Growth Rate: Annual population growth rate (%)
- Plan Start Year: Year the plan starts
- People per Household (Start): People per household at the start of the plan
- Plan End Year: Year the plan ends
- People per Household (End): People per household at the end of the plan
- Water Consumption Requirement: Minimum water consumption required for sewerage systems (L/inhab./day)
- Average Street Width (Optional)
The suggested sanitation system [left] (for the start and end of the plan) and additional recommendations [right] are calculated based on the following decision trees. These results are added as attributes in the generated layer:
Population projections are calculated using a simple linear projection based on the provided annual growth rate and the years of the dataset, plan start, and plan end.
Population density is classified into low, medium, or high density based on the subarea’s projected population.
-
Double-click on 03 - Sanitation System Evaluation under the Scripts > Sanitation Planning section.
-
Select the subarea layer (created in Step Two).
-
Choose a population dataset (raster or vector). If using a vector, specify the field that contains the population data.
-
Input the required parameters.
-
Specify the name and directory for the output layers. The algorithm will generate several layers, clipped by the external boundary of the subarea layer:
- Reprojected and clipped population dataset
- Population points layer (each point represents a pixel or polygon of the population dataset)
- Clipped street layer
- Clipped building footprint layer
- Subarea calculated layer with indicators, sanitation suggestions, and additional recommendations
-
Click Run to execute the algorithm.
IMPORTANT: The Population points, Clipped street, and Building footprint layers must not be deleted or renamed after they are generated. Doing so will cause issues with the recalculation algorithms explained in the following sections.
Tools and scripts have been developed to allow users to make adjustments and modify the parameters of each Subarea Sanitation Suggestion feature individually, if needed, and quickly recalculate the associated indicators and results.
There are two types of adjustments, each with its own recalculation method:
To adjust parameters without altering the geometry:
-
Toggle Edit Mode on the subarea result layer.
-
Select the Identify Features tool.
-
Click on the desired subarea.
-
Modify the parameter(s) in the form.
-
Click the Recalculate Subarea button at the bottom of the form.
-
Click OK to confirm the changes.
-
Save the layer.
To adjust the geometry of subareas:
-
Toggle Edit Mode on the subarea result layer.
-
Use QGIS' native tools to edit the geometries (e.g., move vertices, merge subareas, or subdivide).
-
Run the script 04 - Recalculate Subareas.
-
Select the Subarea Sanitation Suggestion layer.
-
Check the option to Recalculate for changes in geometries.
-
Click Run to execute the recalculation.