I try to mask AOI area on raster image with rasterio
I use rasterio
to mask area of interest and then define the rest extent as no data
My goal is to keep original raster bounds ,select area of interest, but reduce image size
I use following wonderful doc Masking a raster using a shapefile from raterio
website
I changed following line from original procedure
with rasterio.open("tests/data/RGB.byte.tif") as src:
out_image, out_transform = rasterio.mask.mask(src, shapes, crop=True)
out_meta = src.meta
to
with rasterio.open("tests/data/RGB.byte.tif") as src:
out_image, out_transform = rasterio.mask.mask(src, shapes, filled=True , nodata=0)
out_meta = src.meta
Result is here, exactly what I want :
But the new raster file size remains same !! I expect reduce image size to half or more !
So I tried following :
gdal_translate -of GTiff -a_nodata 0 input.tif output.tif
or
gdal_translate -of GTIFF -scale -a_nodata 0 myVrt.vrt output.tif
Both don't help