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

Update of the min_threshold_dist_from_shapefile function to support geopandas objects directly. #436

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions libpysal/weights/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1082,8 +1082,9 @@ def get_points_array_from_shapefile(shapefile):

Parameters
----------
shapefile : string
name of a shape file including suffix
shapefile : string/geopandas.GeoSeries/geopandas.GeoDataFrame
If a string, it must be a full pathname of
a shape file - including suffix

Returns
-------
Expand Down Expand Up @@ -1117,8 +1118,12 @@ def get_points_array_from_shapefile(shapefile):
[ 8.33265837, 14.03162401],
[ 9.01226541, 13.81971908]])
"""

f = psopen(shapefile)
if isinstance(shapefile, str):
f = psopen(shapefile)
elif isinstance(shapefile, gpd.GeoDataFrame):
f = shapefile.geometry
elif isinstance(shapefile, gpd.GeoSeries):
f = shapefile
data = get_points_array(f)
return data

Expand Down