Re: writing raster files produces black tifs
Hobart, Geordie (NRCan/RNCan)
If I understand you correctly, this is a Arc question.
IFF the values exist in your output file. You can test by loading your results file in a new process and rasterio.plot.show().
Arc tries to display a byte file for values between 0-255, hence no contrast between 0 and 1. In Arc, open the layer properties of your new GTiff and adjust the display values under the symbology tab.
If not and the results file is all zeros then it is probably and error in your code. I had a similar issue where I incorrectly set the value NBITS =1 when calling rasterio.open() and on linux systems my output was empty.
From: email@example.com <firstname.lastname@example.org> On Behalf Of Julius Schmiedt
Sent: July 12, 2021 02:18
Subject: [rasterio] writing raster files produces black tifs
I´m quite new to rasterio and Python, but my task is, to produce binary raster files based on the information of sentinel2 satellite images (GTiff). Therefore I use Spyder IDE and the numpy.where() method to calculate new arrays and save them as GTiffs.
Although the output arrays contain 0 and 1 values, the output tif only shows black (in the shape of the original gtiff), if opened with standard image viewer or ArcGIS Desktop. Only if opened via Python script in Spyder, I am able to display the output tifs as expected (using rasterio.plot.show() method).
If anybody has an idea, what the problem might be, I would appreciate any help.