Hey,
After creating my own geojson data in https://geojson.io and adding the id, my Choropleth isnt showing up at all.
Looked at similar posts and found community.plotly.com/t/choropleth-map-not-working-with-my-geojson-data, but the problem isn’t the same as our geojson sources are different
The Choropleth code is simple and taken from another working code. I imagine the issue might be coming from the dataframe used, but I don’t see where.
Data frame
df = pd.DataFrame({"CASES":[104708,389938,340123],
"REGION":["Brussels","Flanders","Wallonia"]})
geojson data
geojson_data = {'type': 'FeatureCollection', 'features': [{'type': 'Feature', 'properties': {}, 'id': 'Wallonia', 'geometry': {'type': 'LineString', 'coordinates': [[3.17779541015625, 50.75470351914962], [3.22723388671875, 50.76339072520501], [3.311004638671875, 50.74688365485319], [3.354949951171875, 50.704285918657924], [3.4565734863281246, 50.761653413004304], [3.54034423828125, 50.75991603629921], [3.5472106933593746, 50.73124000713507], [3.6392211914062504, 50.719069112580804], [3.7023925781249996, 50.77728690074856], [3.7779235839843746, 50.74949042143186], [3.871307373046875, 50.74688365485319], [3.9111328125000004, 50.692108022899525], [4.060821533203125, 50.6964576343863], [4.15283203125, 50.726893622009605], [4.24896240234375, 50.68688795669134], [4.305267333984374, 50.69558774435639], [4.335479736328124, 50.726893622009605], [4.39727783203125, 50.73037076236953], [4.4989013671875, 50.753834709847816], [4.515380859375, 50.73037076236953], [4.590911865234375, 50.75817859508893], [4.63348388671875, 50.74166968624287], [4.6417236328125, 50.798123424528], [4.713134765624999, 50.792047064406866], [4.761199951171875, 50.80246319809847], [4.829864501953125, 50.76512797290213], [4.902648925781249, 50.7720763186707], [4.925994873046875, 50.74340774029213], [4.993286132812499, 50.767733723505344], [5.077056884765625, 50.70602535992328], [5.153961181640625, 50.693847915895624], [5.181427001953125, 50.72428559737425], [5.25970458984375, 50.71559113343383], [5.368194580078125, 50.74340774029213], [5.43548583984375, 50.718199641990765], [5.4656982421875, 50.73210923577103], [5.483551025390625, 50.72254683363231], [5.519256591796875, 50.75557231232454], [5.61126708984375, 50.77728690074856], [5.6524658203125, 50.799859382321195], [5.692291259765625, 50.80246319809847], [5.67718505859375, 50.75817859508893], [5.774688720703125, 50.782496902351625], [5.890045166015625, 50.75470351914962], [6.013641357421874, 50.752965884419], [6.17706298828125, 50.645977340713586], [6.266326904296875, 50.62420185009975], [6.17706298828125, 50.5570699439854], [6.218261718749999, 50.49158967391367], [6.351470947265625, 50.48809484049477], [6.406402587890624, 50.32968303000023], [6.318511962890625, 50.32003871893868], [6.273193359375, 50.2682767372753], [6.17706298828125, 50.23227337810461], [6.189422607421875, 50.17953649586382], [6.14410400390625, 50.16458378401074], [6.1358642578125, 50.13202347092587], [6.1083984375, 50.16458378401074], [6.065826416015625, 50.15490600646736], [6.021881103515625, 50.18305410102734], [5.9600830078125, 50.17074134967256], [5.9600830078125, 50.13114315479007], [5.86669921875, 50.06066538593667], [5.777435302734375, 49.956521395491166], [5.774688720703125, 49.87251263825472], [5.785675048828125, 49.78924409866447], [5.832366943359374, 49.72270359017756], [5.869445800781249, 49.683623991698084], [5.906524658203125, 49.66229459701699], [5.859832763671875, 49.58845831789965], [5.813140869140625, 49.54303352434694], [5.760955810546875, 49.55907063051266], [5.738983154296875, 49.537686652219996], [5.653839111328125, 49.54927080239457], [5.612640380859374, 49.50737665842872], [5.567321777343749, 49.52520834197442], [5.472564697265625, 49.49935027965391], [5.447845458984375, 49.55372551347579], [5.354461669921875, 49.63028296505134], [5.310516357421874, 49.60982006821737], [5.324249267578125, 49.65518272008055], [5.263824462890625, 49.692508478893274], [5.153961181640625, 49.71293663743371], [5.08941650390625, 49.76441298901348], [5.005645751953125, 49.797222824651534], [4.851837158203125, 49.7919038200459], [4.846343994140625, 49.86366109677629], [4.887542724609374, 49.90701815226818], [4.791412353515625, 49.98037086399746], [4.844970703125, 50.09856007224113], [4.89990234375, 50.13466432216694], [4.822998046875, 50.168102490105014], [4.74884033203125, 50.119697571288164], [4.68017578125, 50.0677178281599], [4.692535400390625, 49.99449830610663], [4.585418701171875, 49.98478613540783], [4.511260986328125, 49.948568946378025], [4.343719482421875, 49.95210353033133], [4.306640625, 49.9680059481165], [4.200897216796875, 49.954754298064195], [4.140472412109375, 49.97330558682922], [4.156951904296875, 50.04655739071663], [4.231109619140625, 50.0677178281599], [4.209136962890625, 50.13466432216694], [4.129486083984375, 50.13202347092587], [4.154205322265624, 50.208548992291014], [4.22149658203125, 50.254229882306205], [4.162445068359375, 50.28846183451485], [4.15557861328125, 50.25510793210134], [4.025115966796874, 50.35422335480388], [3.8891601562499996, 50.328806355320204], [3.8081359863281246, 50.3480894622679], [3.71063232421875, 50.30600713631876], [3.668060302734375, 50.409392733941374], [3.607635498046875, 50.495084248830636], [3.500518798828125, 50.488968573084406], [3.511505126953125, 50.5230315428307], [3.478546142578125, 50.53088873891836], [3.372802734375, 50.49421062933561], [3.2794189453125, 50.533507513540435], [3.23272705078125, 50.65903779321195], [3.258819580078125, 50.67557582058605], [3.247833251953125, 50.709504048865405], [3.198394775390625, 50.71385204707258], [3.176422119140625, 50.74949042143186]]}}, {'type': 'Feature', 'properties': {}, 'id': 'Brussels', 'geometry': {'type': 'LineString', 'coordinates': [[4.4803619384765625, 50.793349208080215], [4.449119567871094, 50.80723648352111], [4.455299377441406, 50.81895066209451], [4.475555419921875, 50.819601363652225], [4.4652557373046875, 50.83629960076613], [4.4680023193359375, 50.83933500217973], [4.461479187011719, 50.851908133371225], [4.4391632080078125, 50.85949372842661], [4.4213104248046875, 50.86837814203458], [4.428863525390625, 50.87769412283608], [4.436073303222656, 50.878127378950914], [4.427146911621094, 50.890040343621834], [4.432640075683594, 50.894155023517996], [4.4281768798828125, 50.89891893559338], [4.414443969726562, 50.906280386616075], [4.414100646972656, 50.91255835156951], [4.404487609863281, 50.914290054964695], [4.389381408691406, 50.91017715419199], [4.377021789550781, 50.89805280600983], [4.333076477050781, 50.90108418907049], [4.29290771484375, 50.88852431729138], [4.297370910644531, 50.8802935991031], [4.2798614501953125, 50.86599468504889], [4.289131164550781, 50.85559271935706], [4.282264709472656, 50.83846776477957], [4.259605407714844, 50.83434816702633], [4.2441558837890625, 50.818299951469584], [4.259948730468749, 50.810273774885715], [4.274024963378906, 50.811358473943685], [4.298057556152344, 50.80962294336054], [4.305610656738281, 50.79747242372991], [4.335479736328124, 50.771642077294885], [4.3430328369140625, 50.77511589542784], [4.384231567382812, 50.768385138479694], [4.383201599121094, 50.76360788469468], [4.480018615722656, 50.792047064406866]]}}, {'type': 'Feature', 'properties': {}, 'id': 'Flanders', 'geometry': {'type': 'LineString', 'coordinates': [[3.17230224609375, 50.75904732375726], [3.148956298828125, 50.793783247910106], [3.076171875, 50.7686022747888], [2.94158935546875, 50.74775259317374], [2.90313720703125, 50.693847915895624], [2.849578857421875, 50.72341622356851], [2.8125, 50.71472159831894], [2.7740478515625, 50.752097042863106], [2.7191162109375, 50.812877010308966], [2.6325988769531246, 50.813744723209524], [2.6023864746093746, 50.850174109831975], [2.59552001953125, 50.91688748924508], [2.63397216796875, 50.94631494645956], [2.57904052734375, 51.00079308917475], [2.547454833984375, 51.087997750516124], [2.9498291015625, 51.247303541606165], [3.18603515625, 51.32975356228202], [3.360443115234375, 51.36920841344186], [3.387908935546875, 51.33833359386697], [3.35906982421875, 51.319455404749775], [3.382415771484375, 51.27394421143647], [3.4304809570312496, 51.24300521333463], [3.525238037109375, 51.24558425850245], [3.51287841796875, 51.28511151053991], [3.5870361328124996, 51.29885215199866], [3.7916564941406246, 51.25761789054247], [3.786163330078125, 51.21548639922819], [3.879547119140625, 51.22236764552972], [3.885040283203125, 51.20430218013711], [3.93035888671875, 51.21548639922819], [4.229736328124999, 51.34605424944661], [4.251708984375, 51.372637664637566], [4.329986572265625, 51.376923867455886], [4.35333251953125, 51.35377360451632], [4.423370361328125, 51.37092307114478], [4.383544921875, 51.44801622351376], [4.538726806640625, 51.481382896100975], [4.535980224609375, 51.41976382669734], [4.670562744140625, 51.42404561602713], [4.76806640625, 51.50532341149335], [4.8394775390625, 51.48907943293123], [4.827117919921874, 51.42661449707482], [4.766693115234375, 51.43003944716933], [4.766693115234375, 51.411199044550045], [4.920501708984375, 51.39749205520681], [5.030364990234375, 51.48052764515145], [5.108642578125, 51.4291832337135], [5.079803466796875, 51.390637019843744], [5.137481689453125, 51.31602217169266], [5.20751953125, 51.319455404749775], [5.241851806640625, 51.305720930785526], [5.228118896484375, 51.2765215214227], [5.42724609375, 51.26535213392538], [5.50140380859375, 51.29627609493991], [5.565948486328125, 51.23784668914442], [5.635986328124999, 51.205162601119824], [5.7843017578125, 51.17417731875822], [5.77056884765625, 51.15006324988587], [5.824127197265624, 51.16642774275134], [5.859832763671875, 51.14747885196854], [5.769195556640625, 51.05520733858494], [5.72113037109375, 50.96188665132059], [5.760955810546875, 50.949775776224485], [5.673065185546874, 50.88051021557967], [5.64422607421875, 50.85624291019714], [5.692291259765625, 50.80506686878317]]}}]}
Choropleth
data = [go.Choropleth(geojson = geojson_data,
locations=df["REGION"],
z=df["CASES"])]
layout = go.Layout(title_text='Belgium Covid-19 total cases as of March 25, 2021', geo=dict(fitbounds="locations"))
fig = go.Figure(dict(data=data,layout=layout))
fig.show()
Any clue what’s causing the problem?
Thank you.