After import a raster file and add buffer of 20 meters I want to write a new raster with this dimensions, but getting error: *`import rasterio <br>. from rasterio import features<br> from rasterio import transform <br> from shapely.geometry import shape, Point, Polygon <br> import numpy as np <br> import zipfile,contextlib <br> from io import BytesIO <br> from contextlib import ExitStack <br> #read cloud raster from zip <br> with zipfile.ZipFile('...img/S2B_MSIL2A_20230926T132239_N0509_R038_T22KHC_20230926T171115.SAFE.zip',"r") as zf_: <br> zfiledata=BytesIO(zf_.read('S2B_MSIL2A_20230926T132239_N0509_R038_T22KHC_20230926T171115.SAFE/GRANULE/L2A_T22KHC_A034241_20230926T132553/IMG_DATA/R20m/T22KHC_20230926T132239_SCL_20m.jp2')) with contextlib.ExitStack() as stack: <br> uzFile=stack.enter_context(zf.open('S2B_MSIL2A_20230926T132239_N0509_R038_T22KHC_20230926T171115.SAFE/GRANULE/L2A_T22KHC_A034241_20230926T132553/IMG_DATA/R20m/T22KHC_20230926T132239_SCL_20m.jp2')) <br> _uzFileBytes=stack.enter_context(BytesIO(_uzFile.read()))<br> with rasterio.open(_uzFileBytes) as src_raster:<br> raster_pixels=src_raster.read(1) <br> raster_transform=src_raster.transform <br> raster_meta=src_raster.meta scl_pixels=raster_pixels.copy() <br> #detect pixels with cloud and shadow <br> index_pixels=np.where(np.isin(scl_pixels.astype('float32'),[3,8,9,10]),scl_pixels.astype('float32'),None) <br> cldsdw_rows,cldsdw_cols=np.where(np.array(index_pixels,dtype=np.float32)>0) <br> cldsdw_coords = raster_transform(cldsdw_rows,cldsdw_cols) <br> cldsdw_points = [Point(x, y) for x, y in zip(cldsdw_coords[0], cldsdw_coords[1])] <br> cldsdw_polygon = Polygon(cldsdw_points) <br> cldsdw_bufygon = cldsdw_polygon.buffer(20)<br> ##add buffer 20m<br> cldsdw_features = [{'geometry': shape(geom)} for geom in cldsdw_bufygon.geoms] <br> with rasterio.open('...img/r20moutput.tif', 'w', *raster_meta) as dst: <br> rasterio.features.rasterize(cldsdw_features, dst.write, transform=raster_transform)`*<br> but on write, its getting errors: ... /opt/.virtualenv/visaopq/lib/python3.12/site-packages/rasterio/features.py:336: ShapeSkipWarning: Invalid or empty shape {'geometry': <POLYGON ((799973.998 7735779.078, 800020 7735793.552, 800020 7735840, 80002...>} at index 0 will not be rasterized. warnings.warn( /opt/.virtualenv/visaopq/lib/python3.12/site-packages/rasterio/features.py:336: ShapeSkipWarning: Invalid or empty shape ...warnings.warn( /opt/.virtualenv/visaopq/lib/python3.12/site-packages/rasterio/features.py:336: ShapeSkipWarning: Invalid or empty shape {'geometry': <POLYGON ((903779.055 7780200.043, 903777.76 7780200.126, 903775.841 7780200...>} at index 22 will not be rasterized. warnings.warn( Traceback (most recent call last): File "", line 2, in File "/opt/.virtualenv/visaopq/lib/python3.12/site-packages/rasterio/env.py", line 410, in wrapper return f(*args, **kwds) ^^^^^^^^^^^^^^^^ File "/opt/.virtualenv/visaopq/lib/python3.12/site-packages/rasterio/features.py", line 378, in rasterize if len(out_shape) != 2: ^^^^^^^^^^^^^^ TypeError: object of type 'method' has no len()