# Wasserstein distance / EMD of two sets of 2D weighted points?

I am trying to implement a 2D version of the EMD/Wasserstein Distance to measure the distance of sets of 2D weighted points.

Let $$A = \{a_{1}, a_{2}, ..., a_{m}\}$$, be a weighted point set such that $$a_{i} = \{(x_{i}, w_{i})\}$$ for $$i = 1,...,m$$, where $$x_{i} \in R^{2}$$ or in general $$R^{k}$$ with $$w_{i} \in R^{+} \cup \{0\}$$ being its corresponding weights.

Let $$B$$ be an other set of points.

How would I go about computing the distance between these 2 sets. Moreover how do I implement something like this (Python or pseudocode)?

Mostly I don't know how to treat the 2D histograms (surrogates for the 2 distributions) and do I use the euclidean distance between the points?

Thanks.