1

I have two polygons in Python:

poly1 = shapely.geometry.polygon.Polygon([(3,4), (2,4),(2,2),(3,2)])
poly2 = shapely.geometry.polygon.Polygon([(4,4), (3,4),(3,2),(4,2)])

that look like this:

enter image description here

Obviously the polygons touch in points (3,4) and (3,2).

How could I add this attribute (touches=True/False or 1/0) to each vertex of the Polygon?

4
  • 2
    The shapefile model includes the option for a "measure" property with each vertex. It's intended for mile-markers, but could be used for this. Your issue is one of scale -- You can only store two such properties (in the Z and M slots).
    – Vince
    Commented Jan 19, 2018 at 12:59
  • I didn't think of the M property! Most probably because I see no option how to tell a shapely LinearRing about M...maybe this is worth another question. I'm not sure though if I got your "issue of scale" correctly...I only need one additional attribute besides X and Y, so there is no problem for me. Is that what you meant?
    – countryman
    Commented Jan 19, 2018 at 16:45
  • Yes, solutions that don't scale well are adequate for simple cases, but which become unwieldy when complexity is introduced.
    – Vince
    Commented Jan 20, 2018 at 4:23
  • That's true! Thanks for the explanation! So still a +1 For the not scalable solution in your comment!
    – countryman
    Commented Jan 21, 2018 at 15:02

1 Answer 1

1

As commented by @Vince:

The shapefile model includes the option for a "measure" property with each vertex. It's intended for mile-markers, but could be used for this. Your issue is one of scale -- You can only store two such properties (in the Z and M slots).

You can read more about this, albeit from an ArcObjects rather than shapely perspective, at Work with vertex attributes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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