+ 1

How to plot Choropleth map with folium and geoJson with a undentifed feature.id?

I am following this guide to plot a choropleth map from Folium: https://notebook.community/python-visualization/folium/examples/GeoJSON_and_choropleth CODE: from branca.colormap import linear colormap = linear.OrRd_03.scale( ecuador['Confirmed cases'].min(), ecuador['Confirmed cases'].max()) ecuador_dict=ecuador.set_index('Provinces')['Confirmed cases'] fec_map= folium.Map(zoom_start=6, tiles="OpenStreetMap", control_scale=True, location=[latitude_ec, longitude_ec]) folium.GeoJson(geojson_ec, name='Confirmed cases', style_function=lambda feature: { 'fillColor'= colormap(ecuador_dict[features['properties.dpa_despro']]), 'color': 'black', 'weight': 2, 'dashArray': '5, 5'} ).add_to(fec_map) fec_map GeoJSON: {'type': 'FeatureCollection', 'features': [{'type': 'Feature', 'properties': {'id_prov': 1, 'dpa_provin': '01', 'dpa_despro': 'AZUAY', 'dpa_valor': 0, 'dpa_anio': '2012', 'rei_codigo': '05', 'ren_codigo': '01', 'pee_codigo': '593', 'codigo': 1, 'codigo_1': 1, 'nombre': 'AZUAY', 'pob_mas': 337044, 'pob_fem': 375083, 'pob_tot': 712127, 'si_lee': 591470, 'no_lee': 51920, 'total': 643390, 'analfabeti': 6.7, 'promedio_e': 9.01, 'pobres_nbi': 338073, 'no_pobres': 361875, 'pob_nopob_': 699948, 'densidad': 85.7, 'edad_media': 28.85, 'cartodb_id': 1, 'created_at': '2015-04-20T23:35:12Z', 'updated_at': '2015-04-21T16:01:08Z', 'style': {'fillColor': "{{'color_map_a9738e3f1adf47a2854fb1c61c1f0f7e'}}" However, I am getting this Error: File "<ipython-input-131-1cdbb903e2f9>", line 7 'fillColor'= colormap(ecuador_dict[features['properties.dpa_despro']]), ^ SyntaxError: invalid syntax Please help me to understand the guide and to set the rigth colormap. VARIABLES: ecuador_dict= Provinces AZUAY 10788.0 BOLÍVAR 2120.0 CARCHI 3080.0 CAÑAR 2165.0 CHIMBORAZO 2560.0 COTOPAXI 4612.0 EL ORO 6497.0 ESMERALDAS 4324.0 GALÁPAGOS 228.0 GUAYAS 22588.0 IMBABURA

7th Nov 2020, 4:48 PM
Rosana Rodríguez Milanés
Rosana Rodríguez Milanés - avatar
4 odpowiedzi
+ 1
Please, I di not understsnd your answer
8th Nov 2020, 1:18 PM
Rosana Rodríguez Milanés
Rosana Rodríguez Milanés - avatar
+ 1
This is made in googleCollab. Sololearn playground don't have vidualization abilities
13th Nov 2020, 5:55 PM
Rosana Rodríguez Milanés
Rosana Rodríguez Milanés - avatar
0
Idk
8th Nov 2020, 4:35 AM
Muhammad Syam'un Al-Ghozi
Muhammad Syam'un Al-Ghozi - avatar
0
Idk = I don't know... Wait, is it about color? I was also finding the solving about this. Maybe we can't modify our code with color for some languages. You can use web design to use it I think, like CSS. I don't know why we can't import color in Sololearn... For this question, better if you ask to our moderator...
8th Nov 2020, 8:46 PM
Muhammad Syam'un Al-Ghozi
Muhammad Syam'un Al-Ghozi - avatar