Skip to content

Commit

Permalink
Added docstrings to clip_points and clip_line_poly functions (#66)
Browse files Browse the repository at this point in the history
* Added string documentation to clip_points and clip_line_poly

* added string documentation to clip_points and clip_line_poly

* corrected string documentation in clip_points and clip_line_poly

* revised edits to sting documentation for clip_points and clip_line_poly

* edited PARAMETERS and RETURNS

* Revised extra spacing and PARAMETERS, RETURNS
  • Loading branch information
mcshanec authored and Leah Wasser committed Oct 30, 2018
1 parent 2843887 commit 0fc113f
Showing 1 changed file with 59 additions and 6 deletions.
65 changes: 59 additions & 6 deletions earthpy/clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,35 @@


def clip_points(shp, clip_obj):
'''
Docs Here
'''
""" A function to clip point geometry using geopandas. Takes an
input point geopandas dataframe that will be clipped to the clip_obj
geopandas dataframe.
Points that intersect with the geometry of clip_obj are extracted
and returned.
Parameters
------------------
shp: Geopandas dataframe
Composed of point geometry that is clipped to clip_obj
clip_obj: Geopandas dataframe
Polygon geometry that is used as the reference area for clipping the point data.
The clip_obj's geometry is dissolved into a single geometric feature and intersected
with the points of the shp input.
Returns
-------------------
Geopandas Dataframe:
The returned geopandas dataframe is a subset of shp that intersects
with clip_obj
"""



poly = clip_obj.geometry.unary_union
return(shp[shp.geometry.intersects(poly)])
Expand All @@ -17,9 +43,36 @@ def clip_points(shp, clip_obj):


def clip_line_poly(shp, clip_obj):
'''
docs
'''
"""A function to clip line and polygon data using geopandas.
Takes an input geopandas dataframe that is used as the clipped data, and a second
geopandas dataframe that is used as the clipping object or reference area.
A spatial index is created around the shp input and is then intersected
with the bounding box of the clip_obj.
Data within this intersection is extracted from shp and the resulting
subset is the output of the function.
Parameters
---------------------
shp: Geopandas dataframe
Composed of line or polygon geometry that is clipped to the reference
area provided by the clip_obj
clip_obj: Geopandas dataframe
Composed of polygon geometry that provides the reference area for clipping
the shp input. The clip_obj's geometry is dissolved into a single geometric
feature and intersected with the spatial index of the shp input.
Returns
-----------------------
Geopandas Dataframe:
The returned geopandas dataframe is a clipped subset of shp
that intersects with clip_obj.
"""

# Create a single polygon object for clipping
poly = clip_obj.geometry.unary_union
Expand Down

0 comments on commit 0fc113f

Please sign in to comment.