Processing Graphical Modeler
Processing Graphical Modeler
Processing Graphical Modeler
Modeler
Ujaval Gandhi
2019-03-04
Introduction
GIS Workflows typically involve many steps - with each step gen-
erating intermediate output that is used by the next step. If you
change the input data or want to tweak a parameter, you will need
to run through the entire process again manually. Fortunately,
QGIS has a graphical modeler built-in that can help you define your
workflow and run it with a single invocation. You can also run these
workflows as a batch over a large number of inputs.
3. Once the layer is loaded, you can see the individual points rep-
resenting incidents of piracy locations. Let’s start building our
Processing model to process these layers. Go to Processing →
Graphical Modeler….
10. Now that we have our user inputs defined, we are ready to add
processing steps. All of the processing algorithms are available
to you under the Algorithms tab. The first step in our pipeline
will be to reproject the base layer to the Project CRS. Search for
Reproject layer algorithm and drag it to the canvas. 1 1
Note: The necessity of this repro-
jection step will become clear shortly.
11. In the Reproject layer dialog, select Base Layer as the Input The grid generation algorithm re-
quires us to specify the extent of the
layer. Check the Use project CRS as the Target CRS. Click OK. grid in the unit of the Project CRS.
We can supply this reprojected layer
12. In the Processing Modeler canvas, you will notice a connection to compute this extent.
appear between the + Base Layer input and the Reproject layer
algorithm. This connection indicates the flow of our processing
pipeline. Next step is to create a hexagonal grid. Search for the
Create grid algorithm and drag it to the canvas.
14. Select Grid Size input for Using model input. Repeat the same
process for Vertical Spacing. Click OK.
15. At this point, we have a global hexagonal grid. The grid spans
the full extent of the base layer, including land areas and places
where there are no points. Let’s filter out those grid polygons
where there are no input points. Search for Extract by location
algorithm and drag it to the canvas.
17. Now we have only those grid polygons that contain some input
points. To aggregate these points, we will use Count points in
polygon algorithm. Search and drag it to the canvas.
20. Switch to the main QGIS window. You can find your newly
created model in the Processing Toolbox under Models →
projects → piracy_hexbin. Now it is time to run and test the
model. As our goal is to aggregate the input points over hexag-
onal grids, it is important that the grids are generated using a
equal-area projection. This will ensure that regardless of the lo-
cation of the grid, it will cover exactly the same area. Our model
doesn’t explicitely ask for a CRS, but uses whatever CRS is set
as the Project CRS. Let’s choose a global equal area projection as
the Project CRS. Go to Project → Properties.
21. In the Project Properties dialog, switch to the CRS tab. We will
use a global Mollweide projection for this exercise which is a equal
area projection. Search for Mollweide in the Filter box and select
World_Mollweide EPSG:54009 as the CRS. Click OK.
22. You will see the layers getting reprojected on-the-fly to the
selected CRS. Locate the piracy_hexbin model in the Processing
Toolbox and double-click it.
23. Our Base Layer is the ne_10m_land and the Input Points layer
is ASAM 11 OCT 18. The Grid Size needs to be specified in the
units of the selected CRS. The World_Mollweide CRS unit is
meters, so we specify 100000m (100 Kms) as the Grid Size. Click
Run to start the processing pipeline. Once the process finishes,
click Close.
24. You will see a new layer Aggregated loaded as the result of
the model. As you explore, you will notice the layer contains
an attribute called NUMPOINTS containing the number of piracy
incidents points contained within that grid feature. Let’s style
this layer to display this information better. Right-click the
Aggregated layer and select Properties.
26. Select Simple fill symbol and check the Transparent Stroke
button under Stroke color. This is to make the hexagon edges
transparent.
27. Click the dropdown next to Color ramp and select the Viridis
ramp. Click the dropdown again and select Invert Color Ramp
to reverse the order of color.
28. The Graduated symbology will divide the values in the selected
column into distinct classes and assign a different color to each
of the classes. Select Natural Breaks (Jenks) as the Mode and
click Classify and click OK.
29. Back in the main QGIS window, turn off the ASAM 11 OCT 18
layer. You will see a nice visualization of piracy hotspots across
the globe.