I have two dataframes--one with a polygon (POLYGON Z in region column), and one with one linestring (LINESTRING Z in path column) per row. I was expecting that the following code calling .clip() would apply the polygon mask to each linestring (what I'm trying to accomplish) per the docs, but that does not appear to be happening.

linestrings_cropped = gp.clip(linestrings, polygon.region)

Including a screenshot of the cells from my notebook which demonstrates that the mask is not being applied to each row (the red in the example is outside of the blue polygon).


  • For what it's worth, after trying other possibilities in the API, I found that geopandas.overlay(linestrings, polygon, how='intersection') generates the geometry I need, which (however clunky) I can join with the other data in the linestrings dataframe. However, I don't understand why clip() doesn't do the equivalent. – oskigeo Feb 19 at 1:02
  • You will need to share your data, the code looks okay. – martinfleis Feb 19 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.