-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Limit sliver uses #23
Conversation
… geodataframes, and works even if a geometry collection isn't returned.
|
||
|
||
def test_clip_line_keep_slivers(single_rectangle_gdf, sliver_line): | ||
with pytest.warns(UserWarning): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docstring please :)
else: | ||
raise TypeError("`drop_sliver` does not support {}.".format(type)) | ||
elif (concat.geom_type == "GeometryCollection").any() and not drop_slivers: | ||
polys = ["Polygon", "MultiPolygon"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add a few tactful comments here.
geopandas/tools/clip.py
Outdated
lines = ["LineString", "MultiLineString", "LinearRing"] | ||
points = ["Point", "MultiPoint"] | ||
|
||
poly_check_orig = gdf.geom_type.isin(polys).any() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These three variables are not needed if you just add the boolean values directly in the list below.
geopandas/tools/clip.py
Outdated
|
||
orig_types_total = sum([poly_check_orig, lines_check_orig, points_check_orig]) | ||
|
||
poly_check_clip = concat.geom_type.isin(polys).any() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly - please just add these up in the list below!
@lwasser added in the comments and docstrings, and reformatted the type checks. Hope this is it! |
Codecov Report
@@ Coverage Diff @@
## add-clip #23 +/- ##
============================================
+ Coverage 90.14% 90.37% +0.22%
============================================
Files 22 22
Lines 2161 2171 +10
============================================
+ Hits 1948 1962 +14
+ Misses 213 209 -4
Continue to review full report at Codecov.
|
lines = ["LineString", "MultiLineString", "LinearRing"] | ||
points = ["Point", "MultiPoint"] | ||
|
||
# Check that the gdf submitted is not a multi type GeoDataFrame |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Check that the gdf submitted is not a multi type GeoDataFrame | |
# Check that the gdf does not contain multiple feature types (points, lines and / or polygons) |
Limited
drop_slivers
to only be used on single typepolygon
orline
geodataframes. Additionally, madedrop_slivers
work when a sliver is returned not as a geodataframe, which is apparently possible. This is the behavior when a line returns a point sliver. It doesn't return a geometry collection, just a regular geodataframe with a line and a point in it. So, I added the needed sections and warnings to check for those cases.