0

QGIS(3.22) I'm trying to compare a vector layer to a raster layer by rasterizing the layer to the same pixel size as the raster and then using raster calculator. I just want to know which pixels in the raster layer have a vector feature inside of them. Unfortunately, my raster layer has a large pixel size compared to my vector polygons, so the total vector layer is being rasterized to just 82x83 pixels despite having over 2000 features. Since the features are so small, they aren't often being included in the rasterization because they are not on the center of the pixel. How can I rasterize to where the pixel is a positive as long as a vector is in the square, not necessarily on the center of it? I just need 1s and 0s, so the number of features in a specific square is irrelevant, but I can fix it if you have an idea that generate a layer like that.

1 Answer 1

2

Enable the ALL_TOUCHED rasterization option by adding the -at flag in the "Additional command-line parameters" of the rasterize tool.

-at

Enables the ALL_TOUCHED rasterization option so that all pixels touched by lines or polygons will be updated, not just those on the line render path, or whose center point is within the polygon.

enter image description here

Your Answer

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

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