Open
Description
pointpats predates geopandas and was originally designed around (n,2) arrays of coordinates. It hasnt been updated much over time like the rest of the pysal stack, but today it's much more common to work in geodataframes rather than numpy arrays (even though you can reformat into the structure pointpats expects fairly easily). It might be nice to have something that consumes geodataframes/series and outputs the same.
e.g. instead of (in addition to?) the current weighted_mean_center
which takes and returns arrays, i end up using something like
def attribute_weighted_center(gdf, column):
if column not in gdf.columns:
raise ValueError(
f"`attribute` {column} was passed but is not present in the dataframe"
)
pt = Point(
weighted_mean_center(
df.centroid.get_coordinates()[["x", "y"]].values,
df[column].fillna(0).values,
)
)
return gpd.GeoSeries([pt], crs=gdf.crs)
would that be of general use? If so,
- do we want to allow the existing functions to take/return multiple types (probably not? but we do kind of have that pattern with Graph that can accept geodataframes or arrays).
- do we want a complementary
_from_gdf
set of functions or something?
Metadata
Assignees
Labels
No labels
Activity