Getting objects from a polygon and putting through function

I’m new to Palantir’s tools, so apologize if this is basic. I’m trying to make an application where users can draw a polygon over a number of points on a map, then input both that polygon and the points under it into a custom Python function that outputs a new GeoJSON polygon and displays that. Any guidance on approach or docs would be appreciated. I have the Python code developed and the objects I would like, but plugging it in in Foundry is tricky.

I think if you want the output GeoJSON as its own object(s) then you would have to add this function as a step in Pipeline builder and create an object set with the GeoJSON output as a property on it. Then you should just be able to add the object set and display it on the map with a Geoshape display.

If you only want the GeoJSON as a transient thing, in Workshop you can add the output of the function as a variable. Then if you add a Foundry Map widget, you can go to Interaction > Drawing Tools > Enabled > Drawn Shapes and add the function-backed variable as the variable used.