Skip to content
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

Merged
merged 4 commits into from
Dec 6, 2019
Merged

Limit sliver uses #23

merged 4 commits into from
Dec 6, 2019

Conversation

nkorinek
Copy link

@nkorinek nkorinek commented Dec 5, 2019

Limited drop_slivers to only be used on single type polygon or line geodataframes. Additionally, made drop_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.

… 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):
Copy link
Owner

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"]
Copy link
Owner

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.

lines = ["LineString", "MultiLineString", "LinearRing"]
points = ["Point", "MultiPoint"]

poly_check_orig = gdf.geom_type.isin(polys).any()
Copy link
Owner

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.


orig_types_total = sum([poly_check_orig, lines_check_orig, points_check_orig])

poly_check_clip = concat.geom_type.isin(polys).any()
Copy link
Owner

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!

@nkorinek
Copy link
Author

nkorinek commented Dec 5, 2019

@lwasser added in the comments and docstrings, and reformatted the type checks. Hope this is it!

@codecov-io
Copy link

Codecov Report

Merging #23 into add-clip will increase coverage by 0.22%.
The diff coverage is 95.45%.

Impacted file tree graph

@@             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
Impacted Files Coverage Δ
geopandas/tools/clip.py 98.66% <95.45%> (+6.35%) ⬆️

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 55cb74c...8821143. Read the comment docs.

lines = ["LineString", "MultiLineString", "LinearRing"]
points = ["Point", "MultiPoint"]

# Check that the gdf submitted is not a multi type GeoDataFrame
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
# 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)

@lwasser lwasser merged commit 0d8c78a into lwasser:add-clip Dec 6, 2019
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.

None yet

3 participants