This Map Shows If You Will Get to The Hospital In Time from Anywhere in Thailand

Have you ever wondered if you had an accident in the middle of the night, would you get to the hospital in time? 500k+ API calls and GIS mapping later, we can tell you why.

The Race Against Time

Thailand is one of the most dangerous places in the world and not for the reasons you have seen from the global media. According to WHO’s Global status report on road safety 2015, Thailand has the second highest road traffic-related death rate in the world at 36.2 deaths per 100,000 population losing out only to Libya, and significantly higher than its middle-income neighbors like Vietnam (24.5), Malaysia (24.0), and Indonesia (15.3). Moreover, similar to most countries with a modern lifestyle, leading causes of deaths in Thailand are ischemic heart diseases (12%) and stroke (10%). All these cases — accidents, heart attacks and strokes — have one thing in common: time is of the essence. So far, policymakers have been working in the dark regarding this issue; that is, until we had open government data and decided to do something about it.

People Who Say Data Is The New Oil Forget Oil Needs Refinery

Thailand has an open government data Data.go.th, which serves as an aggregator and/or portal to data sources across the government bodies. According to Global Open Data Index, it currently is at 34% score, compared to Singapore (60%), Philippines (30%), Indonesia (25%), Cambodia (17%), Malaysia (10%) and Myanmar (1%). And as you would expect, despite an above average ranking in the region, the data is less than ideal: no APIs available, most of the data are not formatted, few keys to link across and some of them are even in difficult excel sheets and PDFs.

We’re actually above average

Nonetheless, two datasets in particular caught our attention: road accident statistics from New Year 2008–2015 and locations of health care providers (and the more complete version at Ministry of Public Health). We used the former dataset we created an infographic about the profile of accidents and how you could best avoid it. And from the latter, we asked ourselves: if we, or anyone anywhere, were to have a stroke here and now, would we make it in time to the hospital?

New Year Accident density plotted with kepler.gl

In the ideal world, the hospital location dataset would be complete with latitude and longitude ready to be plugged into GIS; however, if you have noticed, Thailand’s location data are “less than ideal”.

Tough luck, big shots

So we needed to be resourceful and relied on free credits on Google Cloud Platform to perform reverse geocoding of the addresses for all 26,881 healthcare providers (from now on referred to as hospitals) across the country.

Hospitals by service level (color) and number of beds (bubble size) plotted with kepler.gl

Casting A Fishnet Across A Nation

After that, we used ArcGIS to cast a 1-km-by-1-km fishnet across the entire country, resulting in roughly 500,000 fishnet points. Each point represents a location a person could be in case of an emergency. After that, we tried one of the easiest solutions: Euclidean distance. We pretend that every fishnet point and hospital rest on the same plane without any obstruction. With this we match every fishnet point to its “closest” hospitals resulting in the following heat map.

Hospitals and their 50 kilometer radius

A More Realistic Take: Roads, Elevations and Waters

Euclidean distance is a good starting point, but unless you are Superman and can travel in a straight line from one point to another, you would need to go to the hospital by car in case of an emergency (or they would come to pick you up). We rely on the excellent routing GraphHopper API based on OpenStreetMap. The API allows us to find the time traveled by car, disregarding traffic, from one point to another. The API has a free limit of 15,000 calls per day for free tier, so we decided to not do all the combinations of fishnet points and hospitals (500k * 26k = 13M calls) and use it instead to find the time between the point and its Euclidean nearest hospital. This shrinks our API calls down to 500k and allows us to take into account roads (some places seem to be very close to a hospital but it has no road to get there so it takes more time), mountains and bodies of waters (very difficult to get to a hospital from the wilderness).

Lastly, in order to take into account of rather coarse fishnet, instead of simply plotting the time to hospital for each point, we use kernel density estimation and instead plot contours of time taken to the nearest hospital. Plus, it is an interactive MapBox API, where the crosses are hospital locations and contours represent time in minutes to the nearest hospital.

See full interactive map here

Improving Smart Cities The Smart Way

The beauty about this map is that you can see the use case right away. All the areas with red contours are worth a look as to why people take so long to travel from there to the nearest hospital. Maybe it is simply an API glitch or the fact that the geography is extreme (mountains and water bodies) but it immediately gives policymakers a laser-like focus to explore when they are considering healthcare providers especially in rural areas. Zooming into Kampaeng Phet provice, we can clearly see hospitals are clustered within the municipal area, leaving the suburbs relatively separated despite the fact that a lot of population live in the industrial area in the east. If you are a policymaker, this tells you already that you need to deploy more healthcare providers in the middle of the industrial complex.

Another example is one of Thailand most lucrative cities and one of the smart city initiatives Phuket. As you can see, Phuket itself has very well-positioned hospitals across the island. Its neighbor Krabi, however, is not so fortunate, especially looking at Ao Nang, one of the most famous tourist spots, where it could take from 30 to 70 minutes to go from there to the nearest hospital.

Going Forward with Open Government Data

From this exercise, we have found that we can use Thailand’s open government data to create some impactful use cases, but you need to be resourceful and not expect the cleaned and useful data to be handed to you on a silver platter or APIs. One of us works in a government agency and is hoping to continue this project to create a more nuanced map with cooperation from those with domain knowledge in healthcare and policy; for instance, instead of shortest time to any hospital, we can consider which type of hospitals and number of beds. We hope this will be the first of many use cases to come from our open data.

Notes for Nerds

All data manipulations and API calls are documented in our github repo.

I Wish Cognitive Dissonance Were A Fatal Illness