{"id":22579311,"url":"https://github.com/vijay-varadarajan/geospatial-analysis","last_synced_at":"2025-04-10T18:16:21.343Z","repository":{"id":260727695,"uuid":"865399412","full_name":"vijay-varadarajan/Geospatial-Analysis","owner":"vijay-varadarajan","description":"Leveraging geospatial and population data, this project analyzes healthcare accessibility across major locations in all states of India.","archived":false,"fork":false,"pushed_at":"2024-12-11T18:50:26.000Z","size":31973,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T15:52:36.668Z","etag":null,"topics":["geospatial-analysis","healthcare","india","jupyter","python"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vijay-varadarajan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-30T13:21:31.000Z","updated_at":"2024-12-11T18:50:31.000Z","dependencies_parsed_at":"2024-11-02T06:17:15.276Z","dependency_job_id":"4d103285-21c5-41bf-a37d-31bfefb13c6d","html_url":"https://github.com/vijay-varadarajan/Geospatial-Analysis","commit_stats":null,"previous_names":["vijay-varadarajan/geospatial-analysis"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vijay-varadarajan%2FGeospatial-Analysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vijay-varadarajan%2FGeospatial-Analysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vijay-varadarajan%2FGeospatial-Analysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vijay-varadarajan%2FGeospatial-Analysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vijay-varadarajan","download_url":"https://codeload.github.com/vijay-varadarajan/Geospatial-Analysis/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248269729,"owners_count":21075786,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["geospatial-analysis","healthcare","india","jupyter","python"],"created_at":"2024-12-08T05:06:58.796Z","updated_at":"2025-04-10T18:16:21.311Z","avatar_url":"https://github.com/vijay-varadarajan.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Healthcare Accessibility Analysis in India \n(Inspired by Timor Leste Case Study)\n\n## Overview\n\nThis project analyzes healthcare accessibility across India's regions, taking inspiration from a similar study conducted for Timor Leste. The study provides a visual representation of population distribution, hospitals, and areas accessible within a certain time limit around healthcare facilities. It leverages geospatial data and population datasets to identify regions with limited healthcare access and visualize results on interactive maps.\n\nNavigate to ```./Access_analysis_result_maps/``` to view the results of the analysis\n\n## Table of Contents\n\n1. [Project Motivation](#project-motivation)\n2. [Setup](#setup)\n3. [Data Sources](#data-sources)\n4. [Code Walkthrough](#code-walkthrough)\n5. [Visualization](#visualization)\n6. [Results and Insights](#results-and-insights)\n7. [Future Improvements](#future-improvements)\n\n## Project Motivation\n\nInspired by a case study conducted for Timor Leste, this project uses spatial and population data to evaluate healthcare accessibility. The objective is to understand the reach of healthcare facilities across specific regions, identify areas with limited access, and visualize population density and healthcare reach effectively.\n\n## Setup\n\n### Prerequisites\n\nEnsure you have Python 3.x and the following libraries installed:\n\n```bash\npip install folium pandas geopandas hdx-python-api shapely numpy matplotlib gadm\n```\n\n### API Keys\n\nThis project uses the [OpenRouteService API](https://openrouteservice.org/) to generate isochrones (areas accessible within a specified time) around hospitals. Get an API key from OpenRouteService and replace `ors_api_key` in the code.\n\n## Data Sources\n\n1. **Population Data**: Population data at the 1 km² resolution for India from [WorldPop](https://www.worldpop.org/).\n2. **Geospatial Boundaries**: Administrative boundaries from [GADM](https://gadm.org/) using the `GADMDownloader`.\n3. **Healthcare Facilities**: Hospital locations obtained through OpenStreetMap via the Overpass API.\n\n## Code Walkthrough\n\n### 1. Load Libraries\n\nThe following libraries are essential for data processing, mapping, and API integration:\n\n```python\nimport folium as fl\nimport pandas as pd\nimport geopandas as gpd\nfrom hdx.api.configuration import Configuration\nfrom hdx.data.resource import Resource\nimport json\nimport itertools\nfrom shapely.geometry import Polygon, MultiPolygon\nimport time\nimport numpy as np\nfrom gadm import GADMDownloader\n```\n\n### 2. Load and Preprocess Population Data\n\nThe population data file (`ppp_IND_2020_1km_Aggregated_UNadj.csv`) is loaded and processed to focus on specific coordinates and their associated population counts.\n\n```python\npopdf = pd.read_csv('./ppp_IND_2020_1km_Aggregated_UNadj.csv')\npopdf.columns = ['ID', 'xcoord', 'ycoord', 'population']\npop = gpd.GeoDataFrame(popdf, geometry=gpd.points_from_xy(x=popdf.xcoord, y=popdf.ycoord))\n```\n\n### 3. Retrieve Country Boundaries Using GADM\n\nGADMDownloader provides administrative boundaries for the selected region. The code retrieves and filters boundaries for the state (`West Bengal`) and region (`Nadia`).\n\n```python\ndownloader = GADMDownloader(version=\"4.0\")\ncountry_name = \"IND\"\nad_level = 2\ncopygdf = downloader.get_shape_data_by_country_name(country_name=country_name, ad_level=ad_level)\n```\n\n### 4. Map Population Distribution\n\nUsing `folium`, an interactive map displays the population distribution within the region. The population density is represented by the opacity and color intensity of markers based on quartile population values.\n\n```python\nquartile_labels = [0.1, 0.25, 0.5, 1.0]\npopulation_aoi['opacity'] = pd.qcut(population_aoi['population'], 4, labels=quartile_labels)\n```\n\n### 5. Extract and Map Hospital Locations\n\nHospital data for the region is fetched from OpenStreetMap through the Overpass API, creating markers on the map to represent healthcare facilities within the selected area.\n\n```python\noverpass_query = \"\"\"\n[out:json];\narea[\"ISO3166-1\"=\"IN\"][\"admin_level\"=\"2\"];\n(node[\"amenity\"=\"hospital\"](area);\n way[\"amenity\"=\"hospital\"](area);\n rel[\"amenity\"=\"hospital\"](area);\n);\nout center;\n\"\"\"\nresponse = requests.get(overpass_url, params={'data': overpass_query})\ndata = response.json()\n```\n\n### 6. Generate Isochrone Polygons for Hospitals\n\nUsing the OpenRouteService API, isochrone polygons are generated to show the areas accessible within a 30-minute drive from each hospital, providing insights into the regions within reach of healthcare services.\n\n```python\ndef get_isochrone_osm(each_hosp):\n    body = {\"locations\": [[each_hosp.x, each_hosp.y]], \"range\": [1800], \"range_type\": 'time'}\n    response = requests.post('https://api.openrouteservice.org/v2/isochrones/driving-car', json=body, headers=headers)\n    geom = json.loads(response.text)['features'][0]['geometry']\n    return Polygon(geom['coordinates'][0])\n```\n\n### 7. Population Access Analysis\n\nThe project calculates the proportion of the population with hospital access by overlaying population data within the isochrones. This measure helps to determine the percentage of people who can access healthcare services within a specific travel time.\n\n```python\ndef get_pop_count(cachment, pop_data):\n    pop_access = pop_data[pop_data.within(cachment)]\n    return pop_access['population'].sum().round()\n\nselected_hosp['pop_with_access'] = selected_hosp['cachment_area'].apply(get_pop_count, pop_data=population_aoi)\n```\n\n## Visualization\n\nThe map includes:\n\n- **Population Density**: Markers indicate population concentration, with color and size varying by density.\n- **Hospital Locations**: Hospitals are marked, with accessible regions shaded based on the isochrone analysis.\n- The region coloured green suggest good access, while the population in the region coloured red have poor access.\n- **Access Legend**: A legend displays population access levels, indicating areas with high or low accessibility.\n\n## Results and Insights\n\n- **Population with Access**: The percentage of the population with access to healthcare is calculated, giving a quantifiable measure of healthcare reach.\n- **Accessibility Disparity**: Regions with lower access are visually highlighted, providing a focus for policy or healthcare infrastructure improvements.\n- **Interactive Map**: The interactive map allows users to explore population distribution, hospital locations, and accessibility areas.\n\n\u003cdiv style=\"display: flex; flex-wrap: wrap; flex-direction: row\"\u003e\n  \u003cdiv style=\"flex: 1; margin: 3px;\"\u003e\n    \u003cimg src=\"./sample_results/Screenshot%202024-11-02%20102239.png\" alt=\"Wayanad, Kerala\" style=\"width: 75%;\"\u003e\n    \u003cp style=\"text-align: center;\"\u003eWayanad, Kerala\u003c/p\u003e\n  \u003c/div\u003e\n  \u003cdiv style=\"flex: 1; margin: 3px;\"\u003e\n    \u003cimg src=\"./sample_results/Screenshot%202024-11-02%20102403.png\" alt=\"Patna, Bihar\" style=\"width: 75%;\"\u003e\n    \u003cp style=\"text-align: center;\"\u003ePatna, Bihar\u003c/p\u003e\n  \u003c/div\u003e\n  \u003cdiv style=\"flex: 1; margin: 3px;\"\u003e\n    \u003cimg src=\"./sample_results/Screenshot%202024-11-02%20102443.png\" alt=\"Cuddalore, Tamilnadu\" style=\"width: 75%;\"\u003e\n    \u003cp style=\"text-align: center;\"\u003eCuddalore, Tamilnadu\u003c/p\u003e\n  \u003c/div\u003e\n  \u003cdiv style=\"flex: 1; margin: 3px;\"\u003e\n    \u003cimg src=\"./sample_results/Screenshot%202024-11-02%20102657.png\" alt=\"Nadia, West Bengal\" style=\"width: 75%;\"\u003e\n    \u003cp style=\"text-align: center;\"\u003eNadia, West Bengal\u003c/p\u003e\n  \u003c/div\u003e\n  \u003cdiv style=\"flex: 1; margin: 3px;\"\u003e\n    \u003cimg src=\"./sample_results/Screenshot%202024-11-02%20102805.png\" alt=\"Mysore, Karnataka\" style=\"width: 75%;\"\u003e\n    \u003cp style=\"text-align: center;\"\u003eMysore, Karnataka\u003c/p\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n\n\n## Future Improvements\n\n1. **Dynamic Data Integration**: Automate data updates to reflect real-time changes in population or healthcare facilities.\n2. **Addition of Health Services**: Extend the analysis recommend optimal locations to place new healthcare facilities to improve accessibility.\n3. **Accessibility Scenarios**: Include different transport modes or access times (e.g., 15 minutes, 1 hour) to study varying levels of accessibility.\n\nThis project provides a foundational framework for analyzing healthcare accessibility across geographies, inspired by the Timor Leste case study but applied to India's specific regional and demographic context. The visualization and analysis approach can be adapted to other regions or services as required.\n\n## References\n\n[The Timor Leste case study](https://medium.com/towards-data-science/an-open-data-driven-approach-to-optimising-healthcare-facility-locations-using-python-397b3ce38185?sk=9b9ab370d93fb60929511dea42be000d)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvijay-varadarajan%2Fgeospatial-analysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvijay-varadarajan%2Fgeospatial-analysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvijay-varadarajan%2Fgeospatial-analysis/lists"}