Hi there
I’m trying to make a simple map from shapes and it seems that I’m doing something wrong with MultiPolygon processing in plotly (however, geopandas visualization works fine).
Map outline processing code is:
plot_data = []
for index, row in df.iterrows():
if df['geometry'][index].type == 'Polygon':
x, y = row.geometry.exterior.xy
c_x, c_y = row.geometry.centroid.xy
elif df['geometry'][index].type == 'MultiPolygon':
poly = row.geometry
x, y = [], []
c_x, c_y = [], []
for p in poly:
_x, _y = p.exterior.xy
x.append(_x), y.append(_y)
_c_x, _c_y = p.centroid.xy
c_x.append(_c_x), c_y.append(_c_y)
else:
print('stop')
outline = dict(
type = 'scatter',
showlegend = False,
legendgroup = "shapes",
line = dict(color='black', width=1),
x = np.asarray(x),
y = np.asarray(y),
fill = 'toself',
fillcolor = 'purple',
hoverinfo = 'none'
)
plot_data.append(outline)
Can you please tell me what’s wrong?
Also:
Here is a reproducible example: https://github.com/kohrah/rnd_stuff/blob/master/departements-3.ipynb
And link to shapefile: http://biogeo.ucdavis.edu/data/diva/adm/RUS_adm.zip