# Read Shapefile
with fiona.open("/content/drive/My Drive/shapefile/shape_files/lidar_shape.shp", "r") as shapefile:
shapes = [feature["geometry"] for feature in shapefile]
# read imagery file
with rasterio.open("/content/drive/My Drive/shapefile/imagery_trans.tif") as src:
out_image,out_transform = rasterio.mask.mask(src, shapes, crop=True)
out_meta = src.meta
# Save clipped imagery
out_meta.update({"driver": "GTiff",
"height": out_image.shape[1],
"width": out_image.shape[2],
"transform": out_transform})
with rasterio.open("/content/drive/My Drive/shapefile/imagery_trans_clip.tif", "w", **out_meta) as dest:
dest.write(out_image)
I am trying to clip the raster file with the shapefile file. both files have the same coordinates system. This is my code and I am getting the error ( TypeError: can't multiply sequence by non-int of type 'Affine')
errors occurred to this line :- out_image,out_transform = rasterio.mask.mask(src, shapes, crop=True)