API: expose sjoin_nearest, clip and overlay as methods (#2150)

Co-authored-by: Brendan Ward <bcward@astutespruce.com>
Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
This commit is contained in:
Martin Fleischmann
2021-10-03 19:45:07 +02:00
committed by GitHub
co-authored by Brendan Ward Joris Van den Bossche
parent 087858c12a
commit 0a7eebf6d1
14 changed files with 631 additions and 175 deletions
+12 -8
View File
@@ -91,21 +91,25 @@ In a Spatial Join, two geometry objects are merged based on their spatial relati
# Execute spatial join
cities_with_country = geopandas.sjoin(cities, countries, how="inner", predicate='intersects')
cities_with_country = cities.sjoin(countries, how="inner", predicate='intersects')
cities_with_country.head()
GeoPandas provides two spatial-join functions:
- :func:`sjoin`: joins based on binary predicates (intersects, contains, etc.)
- :func:`sjoin_nearest`: joins based on proximity, with the ability to set a maximum search radius.
- :meth:`GeoDataFrame.sjoin`: joins based on binary predicates (intersects, contains, etc.)
- :meth:`GeoDataFrame.sjoin_nearest`: joins based on proximity, with the ability to set a maximum search radius.
.. note::
For historical reasons, both methods are also available as top-level functions :func:`sjoin` and :func:`sjoin_nearest`.
It is recommended to use methods as the functions may be deprecated in the future.
Binary Predicate Joins
~~~~~~~~~~~~~~~~~~~~~~
Binary predicate joins are available via :func:`sjoin`.
Binary predicate joins are available via :meth:`GeoDataFrame.sjoin`.
:func:`sjoin` has two core arguments: ``how`` and ``predicate``.
:meth:`GeoDataFrame.sjoin` has two core arguments: ``how`` and ``predicate``.
**predicate**
@@ -132,7 +136,7 @@ The `how` argument specifies the type of join that will occur and which geometry
:class:`GeoDataFrame`. It accepts the following options:
* ``left``: use the index from the first (or `left_df`) :class:`GeoDataFrame` that you provide
to :func:`sjoin`; retain only the `left_df` geometry column
to :meth:`GeoDataFrame.sjoin`; retain only the `left_df` geometry column
* ``right``: use index from second (or `right_df`); retain only the `right_df` geometry column
* ``inner``: use intersection of index values from both :class:`GeoDataFrame`; retain only the `left_df` geometry column
@@ -143,9 +147,9 @@ point into a circle of appropriate radius, then intersect those buffered circles
Nearest Joins
~~~~~~~~~~~~~
Proximity-based joins can be done via :func:`sjoin_nearest`.
Proximity-based joins can be done via :meth:`GeoDataFrame.sjoin_nearest`.
:func:`sjoin_nearest` shares the ``how`` argument with :func:`sjoin`, and
:meth:`GeoDataFrame.sjoin_nearest` shares the ``how`` argument with :meth:`GeoDataFrame.sjoin`, and
includes two additional arguments: ``max_distance`` and ``distance_col``.
**max_distance**