I have a shapefile (ShapeY) of European extend and want to rasterize each time only a certain area of the shape (ShapeX) (i have the shapes indicating the prevailing extend) with python and QGis.
However so far i have not found a way to write the code in a manner that it already uses Shape X as mask.
My code reads as following:
err = gdal.RasterizeLayer(target_raster, (3,2,1), source_layer1, options=["ATTRIBUTE=%s" % RASTERIZE_COLOR_FIELD1])
The only solution i found was clipping the resulting layer afterwards with Shape X, but this takes significantly much time. I assume there is a smarter way of initially setting the mask while rasterizing?