I have this list:
list = [[0, 5], [0, 3, 6], [1, 2, 4], [1, 7], [0, 1]]
Each element refers to a point with coordinates listed as two arrays:
Lon = [2.0,3.0,5.0,2.0,6.0,1.0,3.0,4.0]
Lat = [4.0,6.0,5.0,3.0,4.0,2.0,1.0,7.0]
I am trying to create an array that is in the following format:
[[Lon_0,Lat_0],[Lon_5,Lat_5]]
[[Lon_0,Lat_0],[Lon_3,Lat_3],[Lon_6,Lat_6]]
...
I tried the zip function but something is missing and I don't know how to move forward:
for m in list:
for n in m:
Coord = zip((Lon[n], Lat[n]))
Any help is appreciated
zip(Lon, Lat)and you're good.zip(Lon, Lat). To turn it into a list use:list(zip(Lon, Lat)).zipwill turn the "inner" list into a tuple. eg:[(Lon_0, Lat_0), (...), ... ].listto something else, saylst. By naming a variablelistyou override thelistconstructor. So, for example, @pask's previous suggestion will not work even though it should.