0

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?

  • 1
    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 Jan 19 '18 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 Jan 19 '18 at 16:45
  • Yes, solutions that don't scale well are adequate for simple cases, but which become unwieldy when complexity is introduced. – Vince Jan 20 '18 at 4:23
  • That's true! Thanks for the explanation! So still a +1 For the not scalable solution in your comment! – countryman Jan 21 '18 at 15:02
0

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, privacy policy and cookie policy

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