Motivated by long-time dynamic analysis of hybrid systems and safety verification problems, this paper addresses fundamental positive invariance issues of an affine dynamical system on a general polyhedron and their applications. Necessary and sufficient algebraic conditions are established for the existence of a positively invariant set of an affine system on a polyhedron using the tools of lexicographic relation and long-time oscillatory dynamic analysis. A linear program based algorithm is proposed to verify these conditions, and its computational complexity is analyzed. The positive invariance results are applied to obtain an explicit characterization of global switching behaviors of piecewise affine systems. Further, the positive invariance techniques developed in this paper are exploited to show the decidability of safety verification of a class of affine dynamics on semialgebraic sets.