2

How do you rasterize a polygon layer into a raster so all cells covered by polygons (i.e. not NoData) will be set to a constant value?

I do this to set cell according to attribute values:

gdal.RasterizeLayer(rasterHdl, [1], featureLayer, options=["ATTRIBUTE=%s" % attributeName])

... but how about burning in a constant?

1

To pass a constant burn value, e.g. 1, using the GDAL Python bindings:

ds = gdal.RasterizeLayer(rasterHdl, [1], featureLayer, burn_values=[1])
ds = None

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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