-
Notifications
You must be signed in to change notification settings - Fork 901
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
Add area averaged mean aggfunc to dissolve #3229
base: main
Are you sure you want to change the base?
Conversation
Have a question on desired behaviour. In the event a polygon and a 1-dimensional geometry type (Point or LineString) are dissolved together. Would we want the area weighted mean to:
|
I would raise an error as area-weighted mean is not defined for other than polygonal geometries. |
Latest update greatly improves readability by using a user-defined function for aggfunc but have run into some issues around the Seems to be a well-documented but perhaps an incompletely resolved issue at this time - pandas-dev/pandas#50538. Continuing to look into it to determine best approach. |
I seem to have opened a can of worms by opting to feed a function to
My view on what we can do next:
It may be worth noting the existing docstring may cause some confusion as it suggests Apologies if I am off the mark in my investigation in this and wasted your time reading this wall of text. |
1c5e88e
to
9e13528
Compare
@nicholas-ys-tan is this ready for review? Asking given the draft status of the PR. |
I have submitted this PR to support using There is a major limitation to this in that the GeoDataFrame must be numeric only (with the exception of the geometry column and any columns listed in In theory, we should have been able to get around this by using the I attempted to submit a PR to address this upstream, but ran into further bugs that made this challenging. I have suspended work there as it was interfering with the work they are already putting in to fix. Support of In the mean time, if we wanted to proceed with this, I have added error catching to disallow any dataframes with non-numeric columns (except geometry and those listed in |
Thanks, yes, it is, I was just writing a comment to where this is now. Some upstream bugs detailed in the comments have enforced some limitations on what dataframes this can be used for, not sure if this is something we would still want to introduce at this time. But perhaps there is a better way to do this which I haven't thought of yet. |
One way around these limitations is to ensure that we intercept Intercepting list input would also be useful but that won't solve any of the |
Thanks @martinfleis , I had actually missed that |
Resolves #3028.
A proposed approach to do an area averaged mean (specific aggfunc argument TBD).
This approach allows us to use the existing pandas aggfunc so the kwargs still take effect.
Have refactored to process geometries first, allowing processing of spatial_average_mean in one
if
statement, instead of having one at the start during non-geometry processing, and one after geometry processing (ref first commit before refactoring).Haven't fully tested the kwargs, nor written unit testing yet, nor documentation. Seeking prelim feedback before progressing further.