I am new user of Python. I would like to change my .shp file that I have astext and it looks something like this (using some loop):
[('POLYGON((5576 309.155 5075170.4966,55 76299.7617 5075169.7026,55 76297.7031 5075169.445,557 6287.5204 5075168.1705,55 76286.9311 5075171.4731,55 76286.88250176 5075171.7454858 9,5576309.13147 582 5075173.0732648 6,5576309.03444 426 5075171.7454858 9,5576309.155 5075170.4966))' ,), ('POLYGON((5576 287.5204 5075168.1705,55 76297.7031 5075169.445,557 6299.7617 5075169.7026,55 76309.155 5075170.4966,55 76309.9005 5075163.301,557 6301.9807 5075162.5819,55 76300.8652 5075162.4806,55 76297.3699 5075162.1632,55 76295.8787 5075162.0278,55 76292.9409 5075161.761,557 6288.7631 5075161.3817,55 76288.2564 5075164.0455,55 76287.5204 5075168.1705))' ,)]
to something like this (for every polygon):
((5576309 5075170,5576299 5075169,5576297 5075169,5576287 5075168,5576286 5075171,5576286 5075171,5576309 5075173,5576309 5075171,5576309 5075170))
I need that for drawing in pygame.
I have long file like that one above and I have to get something like (int int, int int, int int) for every polygon which means I have to separate all the coordinates for each polygon in that file and get (int int, int int...) for them. I don't know if I have explained that well.
If you can help me, I would be grateful :)
[('POLYGON((5576 309.155 5075170.4966,55 76299.7617 5075169.7026,55 76297.7031 5075169.445,557 6287.5204 5075168.1705,55 76286.9311 5075171.4731,55 76286.88250176 5075171.7454858 9,5576309.13147 582 5075173.0732648 6,5576309.03444 426 5075171.7454858 9,5576309.155 5075170.4966))' ,), ('POLYGON((5576 287.5204 5075168.1705,55 76297.7031 5075169.445,557 6299.7617 5075169.7026,55 76309.155 5075170.4966,55 76309.9005 5075163.301,557 6301.9807 5075162.5819,55 76300.8652 5075162.4806,55 76297.3699 5075162.1632,55 76295.8787 5075162.0278,55 76292.9409 5075161.761,557 6288.7631 5075161.3817,55 76288.2564 5075164.0455,55 76287.5204 5075168.1705))' ,)]
to something like this (for every polygon):
((5576309 5075170,5576299 5075169,5576297 5075169,5576287 5075168,5576286 5075171,5576286 5075171,5576309 5075173,5576309 5075171,5576309 5075170))
I need that for drawing in pygame.
I have long file like that one above and I have to get something like (int int, int int, int int) for every polygon which means I have to separate all the coordinates for each polygon in that file and get (int int, int int...) for them. I don't know if I have explained that well.
If you can help me, I would be grateful :)
Comment