Hi, I have a pickle file containing a dictionary of geometrical polygons created using Shapely, matplotlib, and Descartes.
Is there a way to plot the above in Plotly ?
Thank you for your help in advance
Best
Additya Sharma
Hi, I have a pickle file containing a dictionary of geometrical polygons created using Shapely, matplotlib, and Descartes.
Is there a way to plot the above in Plotly ?
Thank you for your help in advance
Best
Additya Sharma
Sure you can! Check this link: Shapes | Python | Plotly
Basically, use go.Figure(go.Scatter(x=x, y=y, fill=βtoselfβ)) where x, y denote the polygon vertices which you can get from a Shapely polygon via x, y = Shapely_poly.exterior.coords.xy
Thank you, this worked for me!!! This easily works when you have single polygons.
In case somebody is dealing with mulitpolygons,
mycoordslist = [list(x.exterior.coords) for x in polygon[key].geoms]
this code would provide a list with coordinates of each polygon (which is a part of the multipolygon)
if I may ask a follow-up question:
is it possible to represent integer values (in a numpy array) as colors (along with a colormap) inside the polygons ?
Thank you in advance for the help
Additya
found a workaround for this:
There is a github project for plotting Shapely objects using Plotly. It support 2D and 3D plotting, control over line styles, colors and so forth.