-
Notifications
You must be signed in to change notification settings - Fork 116
add gdf_zonal_stat to main.py #293
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,24 @@ def zonal_stats(*args, **kwargs): | |
| return a list rather than a generator.""" | ||
| return list(gen_zonal_stats(*args, **kwargs)) | ||
|
|
||
| def gdf_zonal_stats(vectors, *args, **kwargs): | ||
| """The primary zonal statistics entry point. | ||
| All arguments are passed directly to ``gen_zonal_stats``. | ||
| See its docstring for details. | ||
|
|
||
| The difference is that ``gdf_zonal_stats`` will | ||
| return a GeoDataFrame rather than a generator. | ||
| Besides this, we make sure the new gdf as the right | ||
| metadata by conserving the CRS | ||
| """ | ||
|
|
||
| gdf = gpd.GeoDataFrame.from_features( | ||
| list(gen_zonal_stats(vectors, geojson_out=True, *args, **kwargs)) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indeed, I have just tried without the |
||
| ) | ||
| gdf.crs = vectors.crs | ||
|
|
||
| return gdf | ||
|
|
||
|
|
||
| def gen_zonal_stats( | ||
| vectors, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move the
import geopandas as gpdinto the function body and out of the top level. Geopandas must remain optional.