Skip to content
Permalink
Browse files

[FEATURE][processing] New Raster Boolean logical OR/AND algorithms

These algorithms calculate the boolean OR or AND for a set of input
rasters. For AND, if all of the input rasters have a non-zero value
for a pixel, that pixel will be set to 1 in the output raster, otherwise
it will be set to 0. For OR, if ANY of the input rasters have a non-zero
value for a pixel, that pixel will be set to 1 in the output raster,
else 0.

A reference layer parameter specifies an existing raster layer to use
as a reference when creating the output raster. The output raster will
have the same extent, CRS, and pixel dimensions as this layer

By default, a nodata pixel in ANY of the input layers will result in
a nodata pixel in the output raster. If the 'Treat nodata values
as false' option is checked, then nodata inputs will be treated the
same as a 0 input value.

Makes for much simpler raster boolean logic calculation without
the complexity of using the raster calculator (and that's not
always possible to do anyway, e.g. when ANY of the input rasters
has a nodata pixel). It's also scalable dynamic to any number of
input rasters (unlike raster calc), so is more flexible when
used within models.
  • Loading branch information
nyalldawson committed Mar 10, 2019
1 parent bdcacd7 commit b66b94453579e86ce4bf25a1d10438c34f672eba
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -7057,5 +7057,234 @@ tests:
name: expected/dissolved_consecutive_lines.gml
type: vector

- algorithm: native:rasterbooleanand
name: Boolean AND, nodata
params:
DATA_TYPE: 5
INPUT:
params:
- name: custom/raster_boolean1.tif
type: raster
- name: custom/raster_boolean2.tif
type: raster
- name: custom/raster_boolean3.tif
type: raster
type: multi
NODATA_AS_FALSE: false
NO_DATA: -9999.0
REF_LAYER:
name: custom/raster_boolean1.tif
type: raster
results:
OUTPUT:
hash: 96799caed50406d3e31e05a182a6872231f800f01dea126aa9fbafdd
type: rasterhash

- algorithm: native:rasterbooleanand
name: Boolean AND, nodata as false
params:
DATA_TYPE: 5
INPUT:
params:
- name: custom/raster_boolean1.tif
type: raster
- name: custom/raster_boolean2.tif
type: raster
- name: custom/raster_boolean3.tif
type: raster
type: multi
NODATA_AS_FALSE: true
NO_DATA: -9999.0
REF_LAYER:
name: custom/raster_boolean1.tif
type: raster
results:
OUTPUT:
hash: bf225380193226957a2210dc45a9c10dffac5dadcee932459e243456
type: rasterhash

- algorithm: native:rasterbooleanand
name: Boolean AND, resampling
params:
DATA_TYPE: 5
INPUT:
params:
- name: custom/raster_boolean1.tif
type: raster
- name: custom/raster_boolean2.tif
type: raster
- name: custom/raster_boolean3_resample.tif
type: raster
type: multi
NODATA_AS_FALSE: false
NO_DATA: -999.0
REF_LAYER:
name: custom/raster_boolean3.tif
type: raster
results:
OUTPUT:
hash: cdf6edb6afcefc5e80d60fa213df17aae59423019240807f5a49b72d
type: rasterhash

- algorithm: native:rasterbooleanand
name: Boolean AND resample, nodata as false
params:
DATA_TYPE: 5
INPUT:
params:
- name: custom/raster_boolean1.tif
type: raster
- name: custom/raster_boolean2.tif
type: raster
- name: custom/raster_boolean3_resample.tif
type: raster
type: multi
NODATA_AS_FALSE: true
NO_DATA: -9999.0
REF_LAYER:
name: custom/raster_boolean3.tif
type: raster
results:
OUTPUT:
hash: 1de336faba85a6b51684bda85b4f3b954b7e54486632352e05c9fab3
type: rasterhash

- algorithm: native:rasterbooleanand
name: Boolean AND, reference layer
params:
DATA_TYPE: 5
INPUT:
params:
- name: custom/raster_boolean1.tif
type: raster
- name: custom/raster_boolean2.tif
type: raster
- name: custom/raster_boolean3.tif
type: raster
type: multi
NODATA_AS_FALSE: false
NO_DATA: -9999.0
REF_LAYER:
name: custom/raster_boolean3_resample.tif
type: raster
results:
OUTPUT:
hash: dfe0bfc934a9d2a8ab865ad77db4278067830ac8e6f0470a730ad434
type: rasterhash

- algorithm: native:rasterlogicalor
name: Boolean OR
params:
DATA_TYPE: 5
INPUT:
params:
- name: custom/raster_boolean1.tif
type: raster
- name: custom/raster_boolean2.tif
type: raster
- name: custom/raster_boolean3.tif
type: raster
type: multi
NODATA_AS_FALSE: false
NO_DATA: -9999.0
REF_LAYER:
name: custom/raster_boolean1.tif
type: raster
results:
OUTPUT:
hash: d9fe5b26cf76ff58674fd6adeb1933f4b5c9b39ca6f57b876455f167
type: rasterhash

- algorithm: native:rasterlogicalor
name: Boolean OR, nodata as false
params:
DATA_TYPE: 5
INPUT:
params:
- name: custom/raster_boolean1.tif
type: raster
- name: custom/raster_boolean2.tif
type: raster
- name: custom/raster_boolean3.tif
type: raster
type: multi
NODATA_AS_FALSE: true
NO_DATA: -9999.0
REF_LAYER:
name: custom/raster_boolean1.tif
type: raster
results:
OUTPUT:
hash: de7a8dabce3872e6ef1acd4821f7f550ac41a43d5b5914ab4474cec1
type: rasterhash

- algorithm: native:rasterlogicalor
name: Boolean OR resample
params:
DATA_TYPE: 5
INPUT:
params:
- name: custom/raster_boolean1.tif
type: raster
- name: custom/raster_boolean2.tif
type: raster
- name: custom/raster_boolean3_resample.tif
type: raster
type: multi
NODATA_AS_FALSE: false
NO_DATA: -9999.0
REF_LAYER:
name: custom/raster_boolean3.tif
type: raster
results:
OUTPUT:
hash: 56c4396468098a6f421e14682e22bb9cbb14027ed97f99cb8f85f953
type: rasterhash

- algorithm: native:rasterlogicalor
name: Boolean OR resample, nodata as false
params:
DATA_TYPE: 5
INPUT:
params:
- name: custom/raster_boolean1.tif
type: raster
- name: custom/raster_boolean2.tif
type: raster
- name: custom/raster_boolean3_resample.tif
type: raster
type: multi
NODATA_AS_FALSE: true
NO_DATA: -9999.0
REF_LAYER:
name: custom/raster_boolean3.tif
type: raster
results:
OUTPUT:
hash: f8f7a412274c3133aee7fc24e3e6df2ddb52c6bc82663dd25154d3be
type: rasterhash

- algorithm: native:rasterlogicalor
name: Boolean OR, reference layer
params:
DATA_TYPE: 5
INPUT:
params:
- name: custom/raster_boolean1.tif
type: raster
- name: custom/raster_boolean2.tif
type: raster
- name: custom/raster_boolean3.tif
type: raster
type: multi
NODATA_AS_FALSE: false
NO_DATA: -9999.0
REF_LAYER:
name: custom/raster_boolean3_resample.tif
type: raster
results:
OUTPUT:
hash: 6c09e13126e16a267e36c79b0eeba7761422da7bd0387125f4c823e6
type: rasterhash

# See ../README.md for a description of the file format
@@ -79,6 +79,7 @@ SET(QGIS_ANALYSIS_SRCS
processing/qgsalgorithmprojectpointcartesian.cpp
processing/qgsalgorithmpromotetomultipart.cpp
processing/qgsalgorithmrasterlayeruniquevalues.cpp
processing/qgsalgorithmrasterlogicalop.cpp
processing/qgsalgorithmrastersurfacevolume.cpp
processing/qgsalgorithmrasterzonalstats.cpp
processing/qgsalgorithmreclassifybylayer.cpp

0 comments on commit b66b944

Please sign in to comment.
You can’t perform that action at this time.