worldbank / DECAT_Space2Stats

https://worldbank.github.io/DECAT_Space2Stats/
Other
1 stars 1 forks source link

Optional geometry parameter for summary endpoint #13

Closed zacharyDez closed 1 month ago

zacharyDez commented 1 month ago

It may be helpful for API users to obtain a response from the summary endpoint that includes a geometry column. This would remove the need for a user to write custom code that adds the geometry, such as:

import h3
from shapely.geometry import Point

def h3_to_point(h3_id):
    lat, lng = h3.h3_to_geo(h3_id)

    return Point(lng, lat)

We could set the default to None, and support two other options in the endpoint:

  1. Polygon: returns a polygon geometry of the hexagon
  2. Point: returns a point geometry of the centroid of the hexagon

@bpstewar @andresfchamorro; I look forward to your feedback regarding your preferences. Lift is relatively small but I'll wait on your feedback before working on implementation.

bpstewar commented 1 month ago

I think both make sense; I did something similar here when creating h3 indices although I only cared about polygons. https://github.com/worldbank/DECAT_Space2Stats/blob/main/src/h3_helper.py#L49

I think having the option for both would be interesting as the points will make for much lighter output files while maintaining options for vizualization