I found the missing piece in this thread: Create AreaBoundary lines from coordinates
And the final part of the script