OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Folium Choropleth no colors

  • Thread starter Thread starter Edwin
  • Start date Start date
E

Edwin

Guest
I was trying to make map that display density by color using Streamlit, Folium and Pandas. Here is the code:

Code:
import streamlit as st
import pandas as pd
import folium
from streamlit_folium import st_folium

def display_map():
    map = folium.Map(
        location=[-3.539241, 118.941828],
        zoom_start=13,
        scrollWheelZoom=False,
    )

    fol = folium.Choropleth(
        geo_data="data.json",
        df=pd.read_csv("data.csv"),
        columns=("DESA", "KEPADATAN"),
        key_on="feature.properties.DESA",
    )

    fol.geojson.add_to(map)

    st_folium(map, width=700, height=450)



st.title("Population Density Map - Banggae, Majene, Sulawesi Barat")
display_map()

However, the output is only blue with no density at all, all the colors are same.

The goal was to show density by colors.

Another note: the original geo data was in shp that I convert to geojson using Ogre.

Here is the Json data: https://github.com/ezerinz/SIG

Code:
For csv:
DESA,KEPADATAN
BANGGAE,6005
BARU,5466
GALUNG,3395
PAMBOBORANG,2541
PANGALIALI,10693
RANGAS,8582
SOREANG PALIPI,2116
TOTOLI,5232
<p>I was trying to make map that display density by color using Streamlit, Folium and Pandas. Here is the code:</p>
<pre class="lang-py prettyprint-override"><code>import streamlit as st
import pandas as pd
import folium
from streamlit_folium import st_folium

def display_map():
map = folium.Map(
location=[-3.539241, 118.941828],
zoom_start=13,
scrollWheelZoom=False,
)

fol = folium.Choropleth(
geo_data="data.json",
df=pd.read_csv("data.csv"),
columns=("DESA", "KEPADATAN"),
key_on="feature.properties.DESA",
)

fol.geojson.add_to(map)

st_folium(map, width=700, height=450)



st.title("Population Density Map - Banggae, Majene, Sulawesi Barat")
display_map()
</code></pre>
<p>However, the output is only blue with no density at all, all the colors are same.</p>
<p>The goal was to show density by colors.</p>
<p>Another note: the original geo data was in shp that I convert to geojson using Ogre.</p>
<p>Here is the Json data: <a href="https://github.com/ezerinz/SIG" rel="nofollow noreferrer">https://github.com/ezerinz/SIG</a></p>
<pre><code>For csv:
DESA,KEPADATAN
BANGGAE,6005
BARU,5466
GALUNG,3395
PAMBOBORANG,2541
PANGALIALI,10693
RANGAS,8582
SOREANG PALIPI,2116
TOTOLI,5232
</code></pre>
 

Latest posts

I
Replies
0
Views
1
impact christian
I
Top