how to take a line from a text to use as input for a function python
Question: Hi guys I have a text fill with some geodata that looks like this:

[(-76.34666,40.006886),(-76.34666,40.073017),(-76.25411,40.073017),(76.25411,40.006886)]
[(-84.82031,38.403187)),(-84.82031,42.327133),(-80.51862,42.327133),(-80.51862,38.403187)]

now i want to take it line by line as an input for a polygon function. I first
tried to make it with one line befor i try iteration but it wont work. That is
my code for now:

    
    
        from shapely.wkt import loads as load_wkt
        from shapely.geometry import Point, Polygon
    
        f = open('koordinat.txt', 'r')
        line = f.readline()
        p = Polygon(line)
        print (p.centroid)
    

I get all the time the same error by the "p = Polygon(line)" and "A LinearRing
must have at least 3 coordinate tuples" but when take one of the lines and put
it in the function manual it works fine.

Any help? Also an example for a possible iteration would be nice :)


Answer: You're passing a string to `Polygon`, but it's expecting a list of coordinates
(numbers).

Try this:

    
    
    import ast
    line = ast.literal_eval(f.readline())
    

