Collect coordinates of shape drawn in python


I have a simple scatter plot on top of which I hand-annotated some shapes using drawopenpath. Now I want to collect the coordinates of the shape that I have drawn. I realize it can be done with “callbacks”, but I am not sure how. Can someone please help?

fig1 = px.scatter(df, x = "xcoord", y = "ycoord")
fig2 = px.scatter(boundary_df, x="x", y="y")
fig3 = go.Figure(, 

    title_text='Drag to add annotations - use modebar to change drawing tool'

My code with two dataframes.

It is easy to do with the EditControl in dash-leaflet :slight_smile:

Thanks for replying, but I don’t see how? From the page

The EditControl makes it possible to draw and edit vectors and markers. It is powered by Leaflet.draw, but with a custom Dash integration that exposes the visible geometries in geojson format via a geojson property and the edit actions via an action property.

So it collects the points inside the boundary not the coordinates of the shape that I have drawn. Am I missing something?

No, it collects the points you have drawn (the boundary itself, i.e. you get a polygon). That’s what you want, right? Or did I misunderstand? :smiley:

Well I want the coordinates of the path drawn by open drawing. But getting polygon would be one step, would it work for non-map data?

What du you mean by ‘open drawing’? What other information than the polygon coordinates do you need?

drawopenpath creates a Path object instead of a polygon.