How to fix Sequence Contains no Elements Error on C#

Hi all,

I am currently working on a code for attractivity, where my concept is assigning cells to factor like Population, Green Spaces and Residential Spaces. I want to code an attractivity relation among these factors where, Population is attracted to green Spaces and Residential Spaces to Green Spaces. I have several C# components but some of them are not working due to this sequence contains no elements error. I cant seem to find the error within the code, I would appreciate if someone knows how to fix this. Thank you for your help! testGC.gh (29.4 KB)

I think this may be the problem: double maxPop = PopulDistrib.Max();

PopulDistrib is an input which doesn’t have any data, so you cannot find the maximum of it.