3

I have two touching Polygons (two neighbouring counties) and there intersection is a MultiLineString, where:

len(list(counties["King's Co."].intersection(counties["Queen's Co."]).geoms))  
list(counties["King's Co."].intersection(counties["Queen's Co."]).geoms )[0]  
list(counties["King's Co."].intersection(counties["Queen's Co."]).geoms )[1] 

gives:

924
LINESTRING (-7.1060859 53.1680546, -7.1061766 53.1678101)
LINESTRING (-7.1061766 53.1678101, -7.1072205 53.1666679)

I would have expected instead:

len(list(counties["King's Co."].intersection(counties["Queen's Co."]).geoms))
len(list(counties["King's Co."].intersection(counties["Queen's Co."]).geoms)[0])

to give:

1
924

why is intersection giving the result like this? I wish to simplify the borders between a set of bordering counties by reducing the number of points, while at the same time preserving topology.

0

1 Answer 1

3

In your case;

  • mls = a.intersection(b) returns MultiLineString.
  • len(mls)gives you lines' count in mls.
  • gs = mls.geomsreturns GeometrySequenceand len(gs) equals len(mls).

So, len(mls) = len(mls.geoms) = len(list(mls)) = len(list(mls.geoms)). More specifically, it's all about __len__() special class method definition.

Note that len(list(mls)) equals len(list(mls.geoms)), however, list(mls)==list(mls.geoms) returns False(but, of course, lines in the lists have similar geometry)

2
  • But why do I get these 2 point LINESTRINGs? I would like a LINESTRING containing all the boarding points, presuming the counties have a single border with each other.
    – Baz
    Commented Mar 18, 2018 at 8:46
  • There is probably a small gap between them or the points that you think are overlapping in the two counties' polygon are not actually overlapping. Commented Mar 18, 2018 at 18:51

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.