Add bounding polygon function for use in determining spatial extent

review comments 1

add tests

remove unnecessary IN clause