Given a shapely.geometry.linestring: How do you access single vertices using Python?

up vote 5 down vote accepted

From Shapely User Manual:

The defining coordinate values are accessed via the coords property.

from shapely.geometry import LineString
line = LineString([(0, 0), (1, 1)])
for coord in line.coords:
    print(coord)

(0.0, 0.0)
(1.0, 1.0)

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.