# raster statistics by line shape (vector)

I have a georeferenced area where I created 7 raster maps (classified with suitability values from 1 to 5) as I have 7 factors to check e.g. natural reserves, floods, slopes etc. From there I did a weighted overlay raster for the final evaluation. In this area I have a railway corridor (represented by a line) which I buffer at 30 meters. I want to calculate a suitability score from the cells that this buffer contains. For example if the buffer contains 10 cells with value 1, 10 with 2, 20 with 3, 20 with 4 and 40 with 5, the final score will be: (10*1)+(10*2)+(20*3)+(20*4)+(40*5) = 370 points of suitability.

How can I count the number of cells from each value this buffer "touches" and the final sum? If in some way I could clip the raster with the buffer, the new raster of the buffer should contain "value" and "count" and I suppose I could do it from there. I don't know if I need to do the buffer or it can be done with the line shape, since the raster already contains cells of 30m*30m.