I am trying to change the extent of a rasterized shapefile to match that of another raster so it can act as a mask for the latter. Other posts suggest using gdalwarp. However, when using gdalwarp to create a new output it throws me a TypeError: argument of type 'float' is not iterable. Is gdalwarp unable to use float values? Although I can't see this written anywhere as a limitation of the function. Below is my code:
slope_src = r'C:\data\extraction\slope.tif'
mask_src = r'C:\data\buildings\blds.tif'
mask_new = r'C:\data\buildings\blds_mask.tif'
slope_raster = gdal.Open(slope_src)
ulx, xres, xskew, uly, yskew, yres = slope_raster.GetGeoTransform()
xres = 0.4
yres = 0.4
lrx = ulx + (slope_raster.RasterXSize * xres)
lry = uly + (slope_raster.RasterYSize * yres)
subprocess.call(["C:\\PRogram Files\\GRASS GIS 7.3\\extrabin\\gdalwarp.exe", "-te", lrx, lry, ulx, uly, mask_src, mask_new])