I'm attempting to run a CNN model with raster files for environmental observations and I'm trying to import a folder of tiff files as the input for the model. I'm relatively new to python and ML and need help with reading the folder of rasters as a 3d numpy array. Below code has been my attempt at reading the folder with gdal:
flix = r'/Desktop/x'
fliy = r'/Desktop/y'
# in_directory = r'C:\Data'
files_to_process = glob(os.path.join(flix, '*.tif')
for data_path in files_to_process:
raster_dataset = gdal.Open(data_path, gdal.GA_ReadOnly)
Note: I somehow am receiving a syntax error at the for loop definition itself as well.
)
on thefiles_to_process = glob(os.path.join(flix, '*.tif')
line, hence theSyntaxError
. To read into a numpy array, useraster_dataset.ReadAsArray()
gdal.org/api/python/osgeo.gdal.html