Plotting ICMR approved test centers on Google Maps using folium package

In the quest to combat the COVID-19 pandemic, accurate and accessible information about ICMR-approved test centers is crucial. This can be achieved using Python's folium package to create interactive maps showing test center locations.

By combining geospatial data with interactive mapping capabilities, we can help individuals easily locate nearby testing facilities. This article demonstrates how to use the folium package to create dynamic maps, customize markers, and provide informative pop-ups for ICMR-approved test centers.

What is Folium?

The folium package is a Python library that creates interactive maps using the Leaflet.js JavaScript library. It provides a user-friendly interface for generating maps with features like markers, polygons, and custom styling. With folium, you can plot geographical data using various map styles and create interactive web maps directly within Python scripts.

Installation and Setup

First, install the required packages ?

pip install folium pandas

Step-by-Step Implementation

Step 1: Import Libraries and Load Data

import folium
import pandas as pd

# Sample ICMR test center data
test_centers = [
    {'lab': 'AIIMS New Delhi', 'latitude': 28.5672, 'longitude': 77.2100, 'address': 'Ansari Nagar, New Delhi'},
    {'lab': 'PGIMER Chandigarh', 'latitude': 30.7333, 'longitude': 76.7794, 'address': 'Sector 12, Chandigarh'},
    {'lab': 'CMC Vellore', 'latitude': 12.9249, 'longitude': 79.1353, 'address': 'Ida Scudder Road, Vellore'},
    {'lab': 'NIMHANS Bangalore', 'latitude': 12.9432, 'longitude': 77.5957, 'address': 'Hosur Road, Bangalore'},
    {'lab': 'SGPGI Lucknow', 'latitude': 26.8597, 'longitude': 81.0352, 'address': 'Rae Bareli Road, Lucknow'}
]

# Convert to DataFrame
data = pd.DataFrame(test_centers)
print("Sample test center data:")
print(data.head())
Sample test center data:
                 lab   latitude  longitude                       address
0      AIIMS New Delhi    28.5672    77.2100         Ansari Nagar, New Delhi
1    PGIMER Chandigarh    30.7333    76.7794            Sector 12, Chandigarh
2         CMC Vellore    12.9249    79.1353         Ida Scudder Road, Vellore
3   NIMHANS Bangalore    12.9432    77.5957            Hosur Road, Bangalore
4      SGPGI Lucknow    26.8597    81.0352         Rae Bareli Road, Lucknow

Step 2: Create the Base Map

# Create a map centered on India
map_center = [20.5937, 78.9629]  # India's approximate center coordinates
m = folium.Map(location=map_center, zoom_start=5, tiles='OpenStreetMap')

print("Base map created successfully!")
Base map created successfully!

Step 3: Add Markers for Test Centers

import folium
import pandas as pd

# Sample data
test_centers = [
    {'lab': 'AIIMS New Delhi', 'latitude': 28.5672, 'longitude': 77.2100, 'address': 'Ansari Nagar, New Delhi'},
    {'lab': 'PGIMER Chandigarh', 'latitude': 30.7333, 'longitude': 76.7794, 'address': 'Sector 12, Chandigarh'},
    {'lab': 'CMC Vellore', 'latitude': 12.9249, 'longitude': 79.1353, 'address': 'Ida Scudder Road, Vellore'}
]

data = pd.DataFrame(test_centers)
map_center = [20.5937, 78.9629]
m = folium.Map(location=map_center, zoom_start=5)

# Add markers for each test center
for index, row in data.iterrows():
    lat = row['latitude']
    lon = row['longitude']
    name = row['lab']
    address = row['address']
    
    # Create popup content with HTML formatting
    popup_content = f'<strong>{name}</strong><br><br>? {address}'
    
    # Add marker with custom popup
    folium.Marker(
        [lat, lon], 
        popup=folium.Popup(popup_content, max_width=300),
        tooltip=name,
        icon=folium.Icon(color='red', icon='plus', prefix='fa')
    ).add_to(m)

# Save the map
m.save('icmr_test_centers_map.html')
print("Map saved as 'icmr_test_centers_map.html'")
print(f"Total markers added: {len(data)}")
Map saved as 'icmr_test_centers_map.html'
Total markers added: 3

Advanced Features

Adding Marker Clusters

For datasets with many test centers, use marker clustering to improve map performance ?

from folium.plugins import MarkerCluster

# Create map with marker cluster
m = folium.Map(location=[20.5937, 78.9629], zoom_start=5)
marker_cluster = MarkerCluster().add_to(m)

# Add clustered markers
for index, row in data.iterrows():
    folium.Marker(
        [row['latitude'], row['longitude']], 
        popup=f"<strong>{row['lab']}</strong><br>{row['address']}"
    ).add_to(marker_cluster)

Key Features

Feature Description Use Case
Interactive Markers Clickable markers with pop-up information Display test center details
Custom Icons Medical/health-themed marker icons Visual identification of test centers
Marker Clustering Groups nearby markers at lower zoom levels Handle large datasets efficiently
Multiple Tile Layers Different map styles (OpenStreetMap, Satellite) User preference and clarity

Use Cases

  • Healthcare Planning: Identify gaps in test center coverage across regions

  • Public Information: Help citizens find nearby ICMR-approved facilities

  • Government Analytics: Analyze distribution and accessibility of testing infrastructure

  • Emergency Response: Quick identification of testing facilities during health emergencies

Best Practices

  • Use marker clustering for datasets with more than 100 locations

  • Include essential information in popups: name, address, contact details

  • Choose appropriate zoom levels based on geographic coverage

  • Validate latitude/longitude coordinates before plotting

  • Consider mobile-responsive design for public-facing maps

Conclusion

The folium package provides an intuitive solution for plotting ICMR-approved test centers on interactive maps. By combining Python's data processing capabilities with folium's mapping features, we can create valuable tools for healthcare accessibility and planning during health emergencies.

---
Updated on: 2026-03-27T09:43:42+05:30

246 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements