Black border after running rio mask


ts@...
 
Edited

Dear Rasterio developers and users,

I' m masking geotiff files with geojson polygons:

rio mask --overwrite --crop in.tif out.tif --geojson-mask mask.geojson 

Unfortunately after doing so black artificats showing up around the cropped area.



Is there a way to avoid this artifacts?


Sean Gillies
 

Hi,

On Sat, Aug 29, 2020 at 8:52 AM <ts@...> wrote:
Dear Rasterio developers and useers,

I' masking geotiff files with geojson polygons:

rio mask --overwrite --crop in.tif out.tif --geojson-mask mask.geojson 

Unfortunately after doing so black artificats showing up around the cropped area.



Is there a way to avoid this artifacts?


It looks like your input.tif may have lossy compression applied, and the output will have the same compression by default. You might try

rio mask --overwrite --crop in.tif out.tif --geojson-mask mask.geojson --co COMPRESS=NONE

--
Sean Gillies


ts@...
 

Thanks for your help Sean,

I can confirm the black artifacts come from jpeg compression.
I also found this answered which explains the problem in detail:
https://gis.stackexchange.com/a/114453/52871

best regards,

Toni