I was wondering if someone could help me with an error message I am getting. First allow me to brief my workflow
- imported raster image via rasterio.open
- converted raster to array via raster.read(band number)
- did some calculations on the array
- trying to convert the final results into geotiff
But when I am trying to execute my codes I am getting the followin error message:
**AttributeError: 'DatasetReader' object has no attribute 'open'
here are my codes
# Get necessary information
driver = "GTiff"
nlines = raster.height
ncols = raster.width
nbands = raster.count
data_type = "float32"
crs = raster.crs
transform = raster.transform
count = raster.count
file_name = "C:/file_path/file_name.tif"
#Writing the GeoTiff
with raster.open("C:/file_path/file_name.tif", "w",
driver = driver,
height = height,
width = width,
count = count,
dtype = dtype,
crs = crs,
transform = transform) as dst:
dst.write(raster_array)
Trying to write numpy array as GeoTiff
Even checked is my data is a numpy array, and the answer was TRUE