Add per polygon function

Splited script into two files so it can be easier imported into other scripts that need on one polygon processing.