VIP
  • Reports
  • Data Catalogue
  • Weekly Analysis
  • Frontier

On this page

  • Map

Paths

Published

December 8, 2025

Abstract

Simple map of communties with the number of households in each and a tool to allow us to draw paths on them

Map

Below is an interactive map that plots all the communities we are working in.

  • The size of the circle is proportional to the number of households in each community.
  • The color of the circle indicates the district, with blue for Karaga, Green for Mion, and red for the remaining two districts that are located close to each other

You can use the drawing tool to draw a path on the map to create a surveying route.

Note

The map let’s you save the path you created. Please share the file it generates when you click on Export with Simon so he can process it and share back the cleaned path

Code
```{python}
import folium
from folium.plugins import Draw


# Create a map centered on a location
m = folium.Map(
    location=[communities["centroid_lat"].mean(), communities["centroid_lon"].mean()],
    zoom_start=9,
)


# 3. Define a simple function to assign a color based on the 'category' column
def get_color(district):
    if district.lower() == "karaga":
        return "blue"
    elif district.lower() == "mion":
        return "green"
    else:
        return "red"


# 4. Loop through each row in the DataFrame to add a CircleMarker
for idx, row in communities.iterrows():
    # Calculate radius with exponential growth
    # np.exp() provides the exponential scaling.
    # The scaling factor (0.5) is crucial for adjusting the final visual size.
    # You may need to change this factor based on your data's range.
    radius = row["num_hh"] * 25

    # Add the CircleMarker to the map
    folium.Circle(
        location=[row["centroid_lat"], row["centroid_lon"]],
        radius=radius,
        color=get_color(row["district"]),
        fill=True,
        fill_color=get_color(row["district"]),
        fill_opacity=0.6,
        popup=f"Community: {row['community']}<br>Households: {row['num_hh']}",
        tooltip=f"Community: {row['community']}<br>Households: {row['num_hh']}",
    ).add_to(m)

# Add the drawing toolbar
draw = Draw(
    export=True,  # Allows you to export the drawing as a GeoJSON file
    filename="my_route.geojson",
    draw_options={
        "polyline": {"shapeOptions": {"color": "orange"}},
        "polygon": False,
        "circle": False,
        "rectangle": False,
        "marker": False,
        "circlemarker": False,
    },
)
draw.add_to(m)

m
```
Make this Notebook Trusted to load map: File -> Trust Notebook
 
Cookie Preferences