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

Add optional geometry option to summary endpoint #21

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

zacdezgeo
Copy link
Collaborator

What I Changed

Option supports 'point' and 'polygon' keywords. Default is 'None' which would exclude the geometry from the response.

How to Test It

  • Run tests python -m pytest
  • Test with example in notebooks/space2stats_api_demo.ipynb or your variation

Other notes

  • I tried generating an object that we could directly read into a GeoDataframe, but I ran into serialization issues when returning a shapely.Point object in the response. The other alternative would be to build a valid feature collection for a geojson that could be read directly, but that would match our expected Dataframe response. Right now, the solution is to convert the geometry column to a shapely.Point or shapely.Polygon with something like the following:
df['geometry'] = df['geometry'].apply(lambda geom: shape(geom))
gdf = gpd.GeoDataFrame(df, geometry='geometry', crs='EPSG:4326')

Option supports 'point' and 'polygon' keywords. Default is 'None' which would exclude the geometry from the response.
@zacdezgeo zacdezgeo added the enhancement New feature or request label Jul 30, 2024
@zacdezgeo zacdezgeo self-assigned this Jul 30, 2024


def generate_h3_geometries(
h3_ids: List[str], geometry_type: Optional[str]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
h3_ids: List[str], geometry_type: Optional[str]
h3_ids: List[str], geometry_type: Optional[Literal["point", "polygon"]]

@zacdezgeo zacdezgeo merged commit a1c09bc into main Jul 31, 2024
2 checks passed
@zacdezgeo zacdezgeo deleted the feature/optional-geometry branch July 31, 2024 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optional geometry parameter for summary endpoint
3 participants