Thanks Stephen. I'm familiar with using queryByPoint to find the nearest point to another point, but hadn't explored using it with polygons. I'll give it a shot. Still curious about the strange errors I was receiving trying to loop through the layer though.