I am looking a method to removes all duplicate points from a a X,Y,Z file. What i wish to code is remove points that have identical x and y coordinates. The first point survives, all subsequent duplicates are removed.
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.mlab as ml
import matplotlib.delaunay
from matplotlib.mlab import griddata
# my area boundary box
xmax, xmin, ymax, ymin = 640000.06, 636999.83, 6070000.3, 6066999.86
# generate fake data
ndata = 500000
# Generate random data to simulate
x = np.random.randint(xmin, xmax, ndata)
y = np.random.randint(ymin, ymax, ndata)
z = np.random.randint(0,20,ndata)
mypoints = zip(x,y,z)
Thanks in advance for helps and tips!!!
🙂
If you run Python 2.7 or higher, you could use an
OrderedDictas a filter:Apart from filtering, this also preserves the order of the random sequences.
Another receipie can be found at the Python documentation, which can be translated to something like: