I have a list of geodesic points by the format: [lat, long, elevation, index, land/sea binary classifier] in a grid formation with regular spacing throughout the dataset. I'm trying to find all neighbouring points that are land (elv > 0) to the current point in the list.
I keep getting this error: RecursionError: maximum recursion depth exceeded while getting the repr of a list and although I understand the sort of thing that could be causing this, I have no idea how this applies to this situation as I'm not explicitly using recursion. How am I able to remedy this error? How can I understand the problem better as well?
(topLat, bottomLat, westLong, eastLong are the lats and longs for the first and last point in the grid/map to identify points at the edge of the map)
def buildNeighbours(point, dataset):
neighbours = []
ix = int(point[3])
if point[0] != topLat and point[0] != bottomLat and point[1] != westLong and point[1] != eastLong:
nw = dataset[ix - (rowLength + 1)]
n = dataset[ix - rowLength]
ne = dataset[ix - (rowLength - 1)]
e = dataset[ix + 1]
se = dataset[ix + (rowLength + 1)]
s = dataset[ix + rowLength]
sw = dataset[ix + (rowLength - 1)]
w = dataset[ix - 1]
neighbours = [nw, n, ne, e, se, s, sw, w]
point.append(neighbours)
else:
point = []
return point
for point in dataList:
point = buildNeighbours(point, dataList)
print(dataList[2000])
reprwould keep circling back to the top of the nested lists. Your code is really long so I haven't tried to figure out where the problem is. Do you have a shorter version that demonstrates the problem.ifcalculations, python tries to raise an error, but hits a recursion error when generating the error message. Put aprint(repr(point))at the top of the function and it will likely hit. Then you can deal with that.point? It seems like a list of ints or floats but then you append a list to it. Is that intentional?