Hi I'm working with prism data and I already have clipped (masked) rasters (*.bil files) of a specific area for each day of a year. I'd like to open all these rasters with rasterio, convert them into numpy arrays, get the average value for each array, then an 8 day average of daily arrays for the entire year.
The first step to doing this is to open up all the bil files iteratively, an keep the names of the files as the variable names, but I cannot seem to get this to work.
import glob, os import fiona import rasterio from rasterio.mask import mask import numpy path = '/home/demios/Desktop/Prism/Temps' notebook = dict() for filename in [each for each in os.listdir('/home/demios/Desktop/Prism/Temps') if each.endswith('.bil')]: with open(path+'/'+filename, "r+") as filehandle: notebook[filename] = rasterio.open(filehandle)
Near as I can tell this is what my code is supposed start off looking like. It does not seem to do anything though.
open with rasterio having matching variable names as files and append variable names to list "rasterload" while opening
using last "rasterload convert loaded rasters into numpy arrays with iterative date matching variable names and make a list "arraydates" of them.
get average of each "arraydates" into a tuple named "dailyavg" via np.mean(variable)
Average dailyavg every 8 days (ie 1-8, 8-16, 16-24, 24-32) into a new tuple 8 day averages.
Anyone able to provide a path forward?