1

In QGIS, I have two layers: raster and vector (green colored) of the same area of interest. Now, I want to assign "1" to the pixels which lie within the green region, and for the rest assign 0. How can I handle that? Is that possible?

enter image description here

1 Answer 1

1

Rasterize the polygon layer: Menu Raster / Conversion /Rasterize (Vector to Raster)

Set 1 for A fixed value to burn and set Assign a specified nodata value to output bands to Not set. You get a new raster layer with pixels = 1 where the polygons are and 0 everywhere else. Use the desired extent for the new raster (e.g. select the extent and resolution of your existing raster). Be aware that all layers have the same CRS.

enter image description here

Output: white=1, black=0

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.