I tried to use the code on the Rasterio-doc website to write an array as a TIFF to disk https://rasterio.readthedocs.io/en/latest/topics/writing.html
with rasterio.Env():
profile = src.profile
profile.update(
dtype=rasterio.uint8,
count=1,
compress='lzw')
with rasterio.open('example.tif', 'w', **profile) as dst:
dst.write(array.astype(rasterio.uint8), 1)
When I run the code the following error occurs: 'name 'array' is not defined'.
I tried in the last line with 'np.array' instead of 'array' to say that it is a numpy-array but it didn't worked.
CodePudding user response:
The variable 'array' stands for the data that should be written to disk. Create a numpy array as for example:
import numpy as np
array = np.array(my_array_data)
Then you can write this data to disk as described in the tutorial.