1

I need to plot Italy's map with points on it, using plotly and dash libraries. Actually, I've done that using go.scattergeo. But it does not show the borders of provinces. (Generally the quality of map is less than shape file that I have)

I also succeed to plot shape file with scatter points in matplotlib. But I have to plot it in plotly to use in my dashboard.

Is there any way to have a scatter plot with a shape file in plotly?

To have Ideas what's the target I post the photos: This is my dash:

enter image description here

This is shape file with scatter plots on matplotlib:

enter image description here

Sina Kian
  • 9
  • 2

1 Answers1

1

I believe that you should convert your shapefile to a geojson format, or just download a geojson-file with your desired resolution.

You could then use go.Scattermapbox to plot your scatter-plot over the map from your geojson-file. I downloaded a geojson-file from github for the example below (such that it should work if you run the code). The image from my example code ends up looking like this: Scatterplot over Italian regions

from urllib.request import urlopen
import json

with urlopen('https://raw.githubusercontent.com/openpolis/geojson-italy/master/geojson/limits_IT_regions.geojson') as response:
    counties = json.load(response)
import plotly.graph_objects as go

fig = go.Figure(go.Scattermapbox(
    mode = "markers",
    lon = [12.5], lat = [41.9],
    marker = {'size': 5, 'color': ["red"]}))

fig.update_layout(
    mapbox = {
        'style': "white-bg",
        'center': { 'lon': 12.5, 'lat': 41.9},
        'zoom': 4, 'layers': [{
            'source': counties,
            'type':'fill', 'below':'traces','color': 'grey', 'opacity' : 0.2}],
    },
    margin = {'l':0, 'r':0, 'b':0, 't':0})

fig.show()