Unable to load geojson for scattermapbox

Hello,

I’m attempting to load a scattermapbox with some geojson data I have, but am having an issue with being able to read the geojson correctly. I can run the program fine if I set the source to be the url of where the data is. You can see through the code snippet below:

...
app.layout = html.Div( [ dcc.Graph(
    id = 'TxWCD-choropleth',
    figure = dict(
        data = [dict(
            type = 'scattermapbox'
        )],
        layout = dict(
            mapbox   = dict(
                layers =[ layer_t ],
                accesstoken = mapbox_access_token,
                center  = dict(
                    lat = 31.3,
                    lon = -99.2
                ),
                zoom = 5.2,
                style='light'
            ),
            height   = 900,
            autosize = True
        )
    )
)])
...

However, I would like to first load the data and then process the json layers individually. Whenever I do this below the map appears, but not with my geojson and I also get an error inside the inspector terminal:

import dash
import json
import os
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
import geopandas as gpd


# public token
mapbox_access_token = MAPBOX_TOKEN

app = dash.Dash(__name__)

pf = pd.read_json( "https://raw.githubusercontent.com/TNRIS/tx.geojson/master/counties/tx_counties.geojson" )

a = json.loads(pf.iloc[0].to_json())

layer_t = dict(
	sourcetype = "geojson",
	type	   = "fill",
	color      = "#265465",
	source     = a
)

app.layout = html.Div( [ dcc.Graph(
	id = 'TxWCD-choropleth',
	figure = dict(
		data = [dict(
			type = 'scattermapbox'
		)],
		layout = dict(
			mapbox 	 = dict(
				layers = [ layer_t ],
				accesstoken = mapbox_access_token,
				center  = dict(
		            lat = 31.3,
		            lon = -99.2
		        ),
		        zoom = 5.2,
		        style='light'
			),
			height   = 900,
			autosize = True
		)
	)
)])

if __name__ == '__main__':
    app.run_server( port = 8051, debug = True )

If anyone knows of a way to load individual geojson from a larger geojson and not from a single url please let me know.

Thanks!

Brand new first-class geojson choropleths are now available in Dash 1.1.1 :tada: Many thanks to the organization that sponsored this feature :heart: (more about how to sponsor & fund our open source work: https://plot.ly/products/consulting-and-oem).
Resources: