✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

I'm trying to plot some streets with a Geojson using Choroplethmapbox

I’m trying to plot some streets with a Geojson using Choroplethmapbox, however, nothing is displayed in the graph, I’m using the following function

def map_links():
    from urllib.request import urlopen
    import json
    with open('emme_links_geojson.json') as f:
        counties = json.load(f)

    import pandas as pd
    df = pd.read_csv("coordinate_table.csv")

    import plotly.graph_objects as go

    fig = go.Figure(go.Choroplethmapbox(geojson=counties, locations=df.ID, z=df.LENGTH,
                                        colorscale="Viridis", zmin=df.LENGTH.min(), zmax=df.LENGTH.max(),
                                        marker_opacity=0.5, marker_line_width=0))
    fig.update_layout(mapbox_style="carto-positron",
                    mapbox_zoom=10, mapbox_center = {"lat": 6.2259489, "lon": -75.6119972})
    fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
    return(fig)

the geojson file looks like this: (In the features array there are more elements)

My csv file looks like this
table

can someone help me?

Looks like the features in your geojson do not have id fields. They should match the ones passed to locations.

they have id, it is in the properties dict

Then you can use the featureidkey property:

go.Choroplethmapbox(
    # ...,
    featureidkey="properties.ID"
)

@andguez

Chroplethmapbox works with Polygon and MultiPolygon geometry, but the streets are representend by LineString and MultipLIneString. They can be plotted as Scattermapbox. See here an answer to a similar question https://community.plotly.com/t/how-to-plot-a-scattermapbox-with-pandas/33393/7