MultiPolygon and maps

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: rnd_stuff/departements-3.ipynb at master Β· sashakorekov/rnd_stuff Β· GitHub
And link to shapefile: http://biogeo.ucdavis.edu/data/diva/adm/RUS_adm.zip

I tried the code, the problem is in the type of _x and _y. Try adding tolist function to them. Ensure that the lats and lons(X, Y) are in a single list before plotting them in scatter plot.

Hope it helps