I am trying to read the proof of the following lemma (Stacks project, 29.18.2):
Let $X$ be a 1-dimensional integral scheme and $c : X \to \mathrm{Spec}(K)$ a proper morphism to the spectrum of a field $K$. For any invertible rational function $f \in R(X)^*$, the direct image of the associated divisor $\mathrm{div}(f)$ is 0.
Let $f : U \to \mathbb{A}^1_\mathbb{Z}$ be a representative of the rational function, with $U \subset X$ a dense open subscheme. There is supposed to be a canonically associated morphism $g : U \to \mathbb{P}^1_K$; I guess the construction should be something like this: take the composite of $f$ with an isomorphism identifying $\mathbb{A}^1_\mathbb{Z}$ with an affine open subset of $\mathbb{P}^1_\mathbb{Z}$, and the canonical morphism $\mathbb{P}^1_\mathbb{Z} \to \mathbb{P}^1_K$; however I only know about a canonical morphism in the other direction. My first question is, what is the right way to construct this?
Now let $Y$ be the closure of the graph of $g$, i.e. the image of $\Gamma_g : X \to X \times_K \mathbb{P}^1_K$. Now one proves (Stacks, 29.17.3) that the projection morphism $p : Y \to X$ is proper; that the restriction of $p$ to $p^{-1}(U)$ is an isomorphism of schemes; and that the divisor $\mathrm{div}_X(f)$ is equal to the direct image $p_*(\mathrm{div}_Y(f))$ of the divisor associated to $f$ on $Y$ (presumably this means the divisor associated to the rational function $U \times_K \mathbb{P}^1_K \to U \to \mathbb{A}^1_\mathbb{Z}$).
Now to the proof of this lemma. Let $q: Y \to X \times_K \mathbb{P}^1_K \to \mathbb{P}^1_K$ and let $c' : \mathbb{P}^1_K \to \mathrm{Spec}(K)$ be the respective projection morphisms. We want to show $$c_*(\mathrm{div}_X(f)) = c_*(p_*(\mathrm{div}_Y(f))) = c'_*(q_*(\mathrm{div}_Y(f))) = 0$$ Since $\mathrm{dim}(\mathbb{P}^1_K) = 1$ and $q(Y) \subset \mathbb{P}^1_K$ is a closed irreducible subscheme, either the image $q(Y)$ is equal to a closed point or the whole projective line. In the first case, $\mathrm{div}_X(f) = 0$; why?