How to compute the divergence of a measured vector field? The divergence a 2D vector Field $\mathbf{F}(x,y) = F_x(x,y)\, \hat{i} + F_y(x,y)\, \hat{j}$ is defined as
$$\mathrm{div}\,\mathbf{F} = \bigg( \dfrac{\partial F_x}{\partial x} +  \dfrac{\partial F_y}{\partial y}\bigg).$$
This can be calculated IF a function $\mathbf{F}(x,y)$ is given.
How do I compute the divergence if I don't know the function $\mathbf{F}(x,y)$ that describes my vector field but rather I have an array of numbers (noisy) that form a  vector field as depicted below.

I know only the $(x,y)$ coordinates  of the tip and the tail of each vector. Just by looking at the picture below, the field has a negative divergence. How can one calculate the divergence of such a field?

Note: This is a part of the problem  addressed  here
 A: You can use the divergence theorem to approximate the divergence and prevent noise from ruining your approximation.
We have $$\int_C \mathbf{F} \cdot d\mathbf{S} = \int_A (\text{div} \mathbf{F}) dA$$ where the left hand side integral is over the boundary $C$ of any sufficiently nice set $A$ and the right hand side integral is over the set $A$.
Now consider a small area $A$ surrounding the point $p$ and assume that you know $\mathbf{F}$ at some points $q_i$ of $C$. You can then approximate the left integral using the a weighted sum of the $\mathbf{F}(q_i)$. The integral on the right is approximately $ A \text{div} \mathbf{F}(p)$.
Your graph suggests that you know $\mathbf{F}$ on a uniform grid with square cells. For each cell with corners $a_i$ you can find a new cell such that $a_i$ marks the middle of the $i$th edge of the new cell and the outward normal is well defined at $a_i$. You need to rotate 45 degrees to get the new cell. Use the new cell to compute an approximation for the divergence at the center of the new cell.
