Skip to content

ENH: Add clip module - #1128

Merged
jorisvandenbossche merged 75 commits into
geopandas:masterfrom
lwasser:add-clip
Feb 7, 2020
Merged

ENH: Add clip module#1128
jorisvandenbossche merged 75 commits into
geopandas:masterfrom
lwasser:add-clip

Conversation

@lwasser

@lwasser lwasser commented Sep 16, 2019

Copy link
Copy Markdown

Hi Again @jorisvandenbossche

Addressing: #821

This PR is the beginning of adding the clip module to geopandas. As i began to copy things over, i noticed that the data used in our vignette uses data downloaded with an earthpy function. So I will need to refactor it to work here. @nkorinek is actually working on that here:

earthlab/earthpy#414

So this is also a WIP PR. so far tests for this module are working just fine but I want to see what CI has to say as well. I noticed some of the other tests are failing locally but they have nothing to do with what i am adding here. Excited to see this functionality in GeoPandas!!
This pr complements #1127 where i'm updating docs as I contribute.

please say the word if something needs to be changed, fixed, etc!!

Closes #956, closes #821

@codecov

codecov Bot commented Sep 16, 2019

Copy link
Copy Markdown

Codecov Report

Merging #1128 into master will decrease coverage by 0.06%.
The diff coverage is 88.05%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1128      +/-   ##
=========================================
- Coverage   90.06%     90%   -0.07%     
=========================================
  Files          21      22       +1     
  Lines        2094    2161      +67     
=========================================
+ Hits         1886    1945      +59     
- Misses        208     216       +8
Impacted Files Coverage Δ
geopandas/__init__.py 100% <100%> (ø) ⬆️
geopandas/tools/__init__.py 100% <100%> (ø) ⬆️
geopandas/tools/clip.py 87.69% <87.69%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ca6e5e7...6e7b462. Read the comment docs.

@martinfleis martinfleis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good! Looking forward having it implemented. I have made some comments, but nothing critical. I haven't checked tests so far, but that can wait once we'll know what exactly should be tested.
Thank you for moving this from earthpy to geopandas!

Comment thread geopandas/clip.py Outdated
Comment thread geopandas/clip.py Outdated
Comment thread geopandas/clip.py Outdated
Comment thread geopandas/clip.py Outdated
Comment thread geopandas/clip.py Outdated
Comment thread geopandas/clip.py Outdated
Comment thread geopandas/clip.py Outdated
Comment thread geopandas/clip.py Outdated
Comment thread geopandas/clip.py Outdated
Comment thread geopandas/clip.py Outdated
@lwasser

lwasser commented Sep 16, 2019

Copy link
Copy Markdown
Author

thank you @martinfleis i left a question in the issue as well. i just am not sure what the review process is here for geopandas! i am still working on some cleanup but should i go ahead and address your comments first? will there be others that need to review and so I should wait for that input as well? Or just dig in to these first and see if other things come up? thank you!

@martinfleis

Copy link
Copy Markdown
Member

@lwasser It is highly probable that @jorisvandenbossche will leave his comments as well, so you can wait with any changes until then. You can respond to comments where we can expect some kind of discussion though. Or just let us know your thoughts on the comments (they are suggestions, not rock solid requests).

@jorisvandenbossche

Copy link
Copy Markdown
Member

@lwasser you can certainly already start replying to Martin's comments, or updating for comments that seem straightforward. Will try to give this a more detailed look tomorrow. In any case, already thanks for starting the PR!

@jorisvandenbossche jorisvandenbossche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lwasser already added a few questions about the implementation

Comment thread geopandas/clip.py Outdated
Comment thread geopandas/clip.py Outdated
Comment thread geopandas/clip.py Outdated
Comment thread geopandas/clip.py Outdated
Comment thread geopandas/clip.py Outdated
Comment thread geopandas/clip.py Outdated
Comment thread geopandas/clip.py Outdated
@ResidentMario

Copy link
Copy Markdown
Contributor

Nice to see this functionality being worked on. I implemented a clip operation in the geoplot codebase that does similar work.

@lwasser

lwasser commented Sep 30, 2019

Copy link
Copy Markdown
Author

thanks all!! i know i have some more work to do on this PR. i've been slammed this semester but will work on this more THIS WEEK.

Leah Wasser and others added 4 commits September 30, 2019 13:38
use rtree for points too!

Co-Authored-By: Martin Fleischmann <36797143+martinfleis@users.noreply.github.com>
@lwasser

lwasser commented Nov 14, 2019

Copy link
Copy Markdown
Author

hi again @martinfleis and @jorisvandenbossche can you please have another look at this PR? we've spent some time (@nkorinek and myself) working on your comments. my apologies for the slowness of our effort. we are juggling a bunch of different projects right now!!

@jorisvandenbossche

Copy link
Copy Markdown
Member

@lwasser thanks a lot for the update! I will also take a look tomorrow

@lwasser

lwasser commented Nov 14, 2019

Copy link
Copy Markdown
Author

wonderful @jorisvandenbossche ! we will have that CI issue fixed by then as well. it's just a black format issue and i just need to push the commit through!!

@martinfleis martinfleis changed the title Add clip module to geopandas ENH: Add clip module Dec 19, 2019
@lwasser

lwasser commented Jan 17, 2020

Copy link
Copy Markdown
Author

hey there @martinfleis @jorisvandenbossche just checking in on this PR and the time frame for when it might be merged! if there are things that we missed please do say the word.

@jorisvandenbossche

Copy link
Copy Markdown
Member

Hi @lwasser, I hope to finally spend some time again on my geopandas backlog after the holidays the coming days!

@jorisvandenbossche jorisvandenbossche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, sorry for the slow follow-up, but this is looking really good!
I did a pass over the code myself and pushed some clean-ups (which would otherwise be tedious to put as comments), and left a few remaining inline comments / questions.

For the tests, I think it would be good to have at least one test where we actually compare with a known result with intersected geometries (with assert_geodataframe_equal, now most tests only check the types of the output etc). This can be a small test where the result is can be easily constructed manually as well.
Also a test that ensures that the output still has the same crs as the input would be good.

Comment thread geopandas/tools/clip.py
Comment thread geopandas/tools/clip.py Outdated
Comment thread geopandas/tools/clip.py Outdated
Comment thread geopandas/tools/clip.py Outdated
Comment thread geopandas/tools/tests/test_clip.py Outdated
Comment thread geopandas/tools/clip.py Outdated
@lwasser

lwasser commented Feb 4, 2020

Copy link
Copy Markdown
Author

hi team! @martinfleis @ljwolf @jorisvandenbossche i just wanted to check in. i'm currently fairly busy as i'm teaching this semester and working on some tools to support our class!! i will try to have a look at the comments left on this pr. it may however take me some time!!

I'm curious if there are things that you guys would like that you could just add vs things you'd like for me or @nkorinek to work on?

i'm just trying to be sensitive to my time but also i want to see this merged so we can deprecate it from earthpy as there are bugs over there that we've fixed here! Please let me know what you think! This pr has been open for a while so i hadn't expected to be working on it this spring. i'm not complaining as i just want the best for this package and to help where i can. i'm also just short on time right now.
Cheers!

@martinfleis martinfleis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lwasser sorry it takes so long. I'll take care of latest comments in the next couple of days.

Comment thread geopandas/tools/clip.py Outdated
Comment thread geopandas/tools/clip.py Outdated
Comment thread geopandas/tools/clip.py
@lwasser

lwasser commented Feb 4, 2020

Copy link
Copy Markdown
Author

@martinfleis thank you! and please don't apologize! i really understand how much effort it is to maintain these projects and appreciate all of the work. Thank you for working on some of the comments! please let us know where we can chip in. like i said i'm really excited about this being incorporated into geopandas! i will then update all of our lessons accordingly.

@martinfleis

Copy link
Copy Markdown
Member

I have made changes as per comments, to support GeometryCollections, cleaned warnings and conditions for keep_geom_type to do the check only if needed, changed clip_obj to mask (same as in GDAL geoprocessing tools in QGIS) and changed overlap check.

I still want to do couple more tests later today or tomorrow.

@lwasser

lwasser commented Feb 5, 2020

Copy link
Copy Markdown
Author

thank you @martinfleis !!

@jorisvandenbossche jorisvandenbossche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martinfleis thanks for the updates!

Comment thread geopandas/tools/clip.py Outdated
Comment thread geopandas/tools/clip.py Outdated
@martinfleis

Copy link
Copy Markdown
Member

There are no remaining unresolved comments, some tests are using assert_geodataframe_equal and code coverage is 100%. And we are all green.

@jorisvandenbossche shall we merge?

@jorisvandenbossche

Copy link
Copy Markdown
Member

@jorisvandenbossche shall we merge?

Yes, let's do that :)

@jorisvandenbossche
jorisvandenbossche merged commit 0dde1c7 into geopandas:master Feb 7, 2020
@jorisvandenbossche

Copy link
Copy Markdown
Member

@lwasser @nkorinek @martinfleis @ljwolf thanks all for the nice collaborative PR! (and for your patience .. :))

@lwasser

lwasser commented Feb 7, 2020

Copy link
Copy Markdown
Author

@jorisvandenbossche @martinfleis @ljwolf and everyone!! Wow thank you so much for this!! I'm so excited that this is now merged and also excited that we were able to move clip over here where it belongs!! Just curious... when will the next release of geopandas be? I'll then plan to update our online lessons and deprecated clip from earthpy.

@jorisvandenbossche

Copy link
Copy Markdown
Member

when will the next release of geopandas be

-> #1285

lwasser pushed a commit to lwasser/geopandas that referenced this pull request Apr 8, 2020
Co-authored-by: Martin Fleischmann <martin@martinfleischmann.net>
Co-authored-by: Nathan Korinek <nako1890@colorado.edu>
Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clipping example for docs Functions to Clip Point, Line and Polygon Data Like Those that exist in other spatial GIS tools

6 participants