title: Shapely geometry intersection - in which cases a line string and polygon would intersect?
body: <p><a href="http://i.stack.imgur.com/XLOzd.png" rel="nofollow">Attached image shows the LineString or rather LineRing and a polygon. I expect them to intersect but they don not as per shapely intersects</a>I have two geometries which i expected to intersect. But they do not. One is a line string (which forms a ring ) and other a little square polygon that is totally inside the line string. It does not touch any of the line string points. 
  Looking at shapely intersection documentation, i expected them to intersect, but they don;t. </p>
  
  <pre><code>geom1 = LINESTRING (-68.41186519999999 -19.429039, -68.35556029999999 -19.5293773, -68.24775699999999 -19.5717596, -68.1444168 -19.6110584, -68.0488014 -19.5375473, -67.87353520000001 -19.5287301, -67.75165560000001 -19.4610893, -67.67972949999999 -19.4220778, -67.7508831 -19.389615, -67.9814672 -19.3241436, -68.0075276 -19.2455493, -67.9786563 -19.1669174, -68.0376756 -19.0532041, -68.10563740000001 -19.1637403, -68.14785809999999 -19.1696967, -68.1900787 -19.1185707, -68.25668330000001 -19.1775984, -68.3349609 -19.1970534, -68.3638 -19.2152094, -68.4386444 -19.2709616, -68.44757079999999 -19.3370618, -68.41186519999999 -19.429039)
  
  Geom2 = tile_polygon_geom = MULTIPOLYGON (((-68.203125 -19.331878, -68.203125 -19.352611, -68.181152 -19.352611, -68.181152 -19.331878, -68.203125 -19.331878)))
  </code></pre>
  
  <p>If i edit the LINESTRING to a polygon - kept the same points, just changed the test LINESTRING to POLYGON i see the outer and inner polygon intersect.  </p>
  
  <pre><code>("POLYGON((-68.41186519999999 -19.429039, -68.35556029999999 -19.5293773, -68.24775699999999 -19.5717596, -68.1444168 -19.6110584, -68.0488014 -19.5375473, -67.87353520000001 -19.5287301, -67.75165560000001 -19.4610893, -67.67972949999999 -19.4220778, -67.7508831 -19.389615, -67.9814672 -19.3241436, -68.0075276 -19.2455493, -67.9786563 -19.1669174, -68.0376756 -19.0532041, -68.10563740000001 -19.1637403, -68.14785809999999 -19.1696967, -68.1900787 -19.1185707, -68.25668330000001 -19.1775984, -68.3349609 -19.1970534, -68.3638 -19.2152094, -68.4386444 -19.2709616, -68.44757079999999 -19.3370618, -68.41186519999999 -19.429039))”)
  </code></pre>
  
  <p>i.e. the code The following code prints "geometries intersect"</p>
  
  <pre><code>geometry1 =  wktloads ("POLYGON((-68.41186519999999 -19.429039, -68.35556029999999 -19.5293773, -68.24775699999999 -19.5717596, -68.1444168 -19.6110584, -68.0488014 -19.5375473, -67.87353520000001 -19.5287301, -67.75165560000001 -19.4610893, -67.67972949999999 -19.4220778, -67.7508831 -19.389615, -67.9814672 -19.3241436, -68.0075276 -19.2455493, -67.9786563 -19.1669174, -68.0376756 -19.0532041, -68.10563740000001 -19.1637403, -68.14785809999999 -19.1696967, -68.1900787 -19.1185707, -68.25668330000001 -19.1775984, -68.3349609 -19.1970534, -68.3638 -19.2152094, -68.4386444 -19.2709616, -68.44757079999999 -19.3370618, -68.41186519999999 -19.429039))”)
  
  gepmetry2 = wktloads ( "MULTIPOLYGON (((-68.203125 -19.331878, -68.203125 -19.352611, -68.181152 -19.352611, -68.181152 -19.331878, -68.203125 -19.331878)))")
  
  if geometry1.intersects(gepmetry2):
      self.logger.info("geometries intersect")
  else:
      self.logger.info("geometries do not intersect")
  </code></pre>
  
  <p>Can someone explain what would be intersection of LINESTRING and a polygon if:
  1) polygon lines and the line string cross at some point
  2) polygon is enclosed within a line string, no points touching
  3) Linestring is fully enclosed within the polygon, no points touching</p>
  
  <p>As i mentioned, I am expecting #2 to return true but it does not. </p>
  
  <p>Documentation I am referring to: http://toblerity.org/shapely/manual.html</p>
  
  <p>object.intersects(other)
  Returns True if the boundary and interior of the object intersect in any way with those of the other.</p>
  
  <p>This predicate is equivalent to the OR-ing of contains(), crosses(), equals(), touches(), and within().</p>
  
  <p>Thanks!</p>