alex_bn_lee

导航

[987] geopandas.sjoin

geopandas.sjoin: Spatial join of two GeoDataFrames.

geopandas.sjoin(left_df, right_df, how='inner', predicate='intersects', lsuffix='left', rsuffix='right', **kwargs)

Parameters:

left_df, right_df: GeoDataFrames
how: string, default ‘inner’

The type of join:

  • ‘left’: use keys from left_df; retain only left_df geometry column

  • ‘right’: use keys from right_df; retain only right_df geometry column

  • ‘inner’: use intersection of keys from both dfs; retain only left_df geometry column

predicate: string, default ‘intersects’

Binary predicate. Valid values are determined by the spatial index used. You can check the valid values in left_df or right_df as left_df.sindex.valid_query_predicates or right_df.sindex.valid_query_predicates Replaces deprecated op parameter.

lsuffix: string, default ‘left’

Suffix to apply to overlapping column names (left GeoDataFrame).

rsuffix: string, default ‘right’

Suffix to apply to overlapping column names (right GeoDataFrame).


Example:

# gdf_Kurnell: point
# gdf_Cadastre: polygon

# left point 'within' right polyogn
joined_gdf = gpd.sjoin(gdf_Kurnell, gdf_Cadastre, predicate='within')

# left polygon 'contains' right point
joined_gdf_re = gpd.sjoin(gdf_Cadastre, gdf_Kurnell, predicate='contains')

 

posted on 2024-04-23 11:42  McDelfino  阅读(38)  评论(0编辑  收藏  举报