# QGIS Raster Calculator equivalent for making a binary raster?

**URL:** <https://discourse.julialang.org/t/qgis-raster-calculator-equivalent-for-making-a-binary-raster/114211>\
**Category:** New to Julia\
**Tags:** geo\
**Created:** [May 14, 2024, 12:36am UTC](https://discourse.julialang.org/t/qgis-raster-calculator-equivalent-for-making-a-binary-raster/114211 "2024-05-14T00:36:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rholland4julia](https://avatars.discourse-cdn.com/v4/letter/r/6f9a4e/32.png) [@rholland4julia](https://discourse.julialang.org/u/rholland4julia)\
**Post date:** [May 14, 2024, 12:36am UTC](https://discourse.julialang.org/t/qgis-raster-calculator-equivalent-for-making-a-binary-raster/114211/1 "2024-05-14T00:36:55Z")

</div>

Is there a way to use the Rasters.jl library to obtain the same effect as the Raster Calculator in QGIS for creating a binary raster? (Where the raster = 1 if it meets the logical criterion, but 0 otherwise).

---

<div class="post-metadata">

**Author:** ![consumere](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/consumere/32/209031_2.png) [@consumere](https://discourse.julialang.org/u/consumere)\
**Post date:** [May 14, 2024, 9:42am UTC](https://discourse.julialang.org/t/qgis-raster-calculator-equivalent-for-making-a-binary-raster/114211/2 "2024-05-14T09:42:17Z")

</div>

you could check out  
` @doc Rasters.boolmask`  
`boolmask(obj::Raster; [missingval])`  
`boolmask(obj; [to, res, size])`  
`boolmask(obj::RasterStack; alllayers = true, kw...)`  
to create a mask array of Bool values, from another Raster.

From a Condition, say `lowerbound < valuerange_you_want < upperbound`  
one could do  
`zm = (ds .> lowerbound ) .& (ds .<= upperbound)`  
`zm = boolmask(zm)`  
`A = Rasters.mask(ds; with=zm)`  
where  
`ds` is a 2D Raster
