Quantcast
Channel: maps for developers - Medium
Viewing all articles
Browse latest Browse all 2230

Build a dashboard for healthcare resource planning — Part I

$
0
0

By: Allan Walker

This is Part I in a series of projects for understanding and analyzing healthcare provider data. Derive business insights from spatial data using this workflow for building a dashboard app with QGIS, Tableau, and Studio.

Healthcare providers have a lot of data to analyze. Tableau makes it easy to understand big data. Mapbox makes it easy to create detailed maps for web and mobile platforms. Both of these tools work together so providers can build dashboard applications and manage all of their data in one place.

For this project, I created a dashboard exploring how many people live near healthcare facilities. I imagined this would be useful for resource planning internally, but you could expand the concept to consumer-facing tools, for example, a map interface where customers can search for in-network providers. I’ll walk through my entire workflow for creating the map, styling the data, and building a dashboard using only visual tools — no coding required.

Click through to explore the dashboard

Start building the background map

Using my NASA EARTHDATA account, I downloaded the 2015 Gridded Population of the World from NASA SEDAC (Socioeconomic Data and Applications Center) in GeoTIFF format, where the grids represent approximately 1 square kilometer with the count of population at each grid.

Population Count v4.10 2015, Gridded Population of the World. Courtesy NASA/SEDAC/Columbia University in the City of New York

Getting the map ready for Mapbox using QGIS and Tippecanoe

All of the gridded earth population data I downloaded is in raster format — a spatial data structure comprised of pixels encoded with data values. For the dashboard, this data needs to be converted to a vector format, where the data is displayed with symbolic shapes (points, lines, polygons) as opposed to pixel values. Vector data has vertices and paths so it’s easier to do an analysis of where the grids of population values intersect with Health Facilities data.

I used QGIS, an open source GIS software tool, to manipulate the data so it’s ready to be viewed in a web dashboard.

  1. Add raster data to QGIS: Menu → Layer → Add Raster Layer (navigate to the downloaded GeoTIFF)
GPW v4 with Population Counts GeoTIFF Raster in QGIS

2. Add a vector layer for making base map: Menu → Layer → Add Vector Layer (navigate to USGS TIGER/Line® ESRI Shapefile “States”). Save the Vector Layer with the same projection as the Raster (WGS 84: EPSG 4326). We are going to “Clip” the world raster image with the States file — the area of interest.

3. Clip raster data: Menu → Raster → Extraction → Clipper → Input Layer (Raster) & Mask Layer (Vector) and select the “crop the extent” option | Output is the Clipped Raster.

Clipping GPW v4 GeoTIFF with USGS Tiger/Line ESRI Shapefile States as a Mask

4. Convert raster to vector: Menu → Raster → Conversion → Polygonize → Input Layer (Clipped Raster) and choose the Field Name option with a field name of Pop1Km | Output USAPOP1KM.geojson file for the background map. Essentially, I’m creating a vector from the raster image.

Output USAPOP1KM.geojson file rendered using QGIS

The USAPOP1KM.geojson is a huge file (1.6Gb) so I used Tippecanoe to generate Mapbox Vector Tiles, an efficient format for our web dashboard.

Tippecanoe is a Command Line Interface tool. I typed “cd” in my Mac OS terminal to navigate to the directory where the converted GeoJSON is saved. I then typed:

tippecanoe -o USAPOP1KM.mbtiles -Z4 -z12 -aN USAPOP1KM.geojson

What that is doing is instructing Tippecanoe to output Mapbox Vector Tiles with a name of USAPOP1KM.mbtiles, a minimum zoom of 4, and a maximum zoom of 12, using the USAPOP1KM.geojson file. The -aN switch dynamically combines small features. This helps with file compression by coalescing the polygons.

Use Mapbox Studio to customize the map for Tableau

I uploaded USAPOP1KM.mbtiles as a tileset in Mapbox Studio and created a new layer called Health. I chose the Mapbox Dark style for the base map and then added the USAPOP1KM tileset. I styled the layer with the same color and breaks as I used in QGIS, setting the opacity to 25%. This allows the base-map detail to show through.

USAPOP1KM visualized in Mapbox Studio

Clicking “Share, develop, & use”, the button next to the style list, gives you the integration URL so the map can be referenced in Tableau.

Select Tableau from the list:

Adding this map to the Tableau dashboard we’ll build later is as simple as copy/pasting the link.

Prep the provider data for Tableau in QGIS

USGS has a comprehensive database of structures as open data; it’s part of the National Map. Download the file and consult the Best Practices Data Model, we’ll reference this to filter the dataset down for Health Facilities.

  1. Open file in QGIS: I saved the Shapefile as 4326Structures.geojson with a CRS of EPSG:4326 (the same as our background map).
Saving the USGS Structures ESRI Shapefile as geojson with EPSG:4326 WGS 84 projection

2. Filter data: I then filtered the dataset for Health Facilities based on FTYPE = 800 as per the Best Practices Model.

Filtering the dataset for Health Facilities

3. Get pop value for each grid: Next, I Intersected the Health Facilities with the USAPOP1KM.geojson file to obtain the population value for the grid the point is in (Menu → Vector → Geoprocessing → Intersection | output file IntersectionPop.geojson)

Intersecting Health Facilities with Population Grid Values

4. Get County names: I intersected the IntersectedPOP.geojson with the USGS TIGER/Line® ESRI Shapefile “Counties” file to obtain the name of the County that the point is in (remember to save the Counties file with a CRS of EPSG:4326 first)

5. Save as CSV: I saved the output as HEALTHFACILTIES.csv and obtained the Latitudes and Longitudes values by setting the Geometry to the AS_XY option.

Saving the Dataset as CSV with Latitude and Longitude values

How I built the Tableau dashboard

  1. Import the CSV into Tableau: Connect → Text File → Navigate to HEALTHFACILTIES.csv
  2. Create two worksheets: Call one Map and the other Chart
  3. Set geographic role: Change “X” to Longitude and “Y” to Latitude
Changing the Geographic Role in Tableau

4. Create the chart: I set up the chart worksheet as a dual axis “lollipop” chart with a Calculated Field for color to match the breaks of the background map.

Calculated Field for Dual Axis Lollipop chart in Tableau

5. Add the map: I set up the map worksheet as a scatterplot, with X on Columns and Y on Rows, and cut/paste’d my Mapbox Integration URL (Menu → Map → Background Maps → Map Services → Add → Mapbox Maps)

Adding a Mapbox Background Map by cutting and pasting the Integration URL

6. Finishing touches: Finally, I built out the dashboard by adding the worksheets and the filters (Menu → Analysis → Filters) with a Title and a caveat that recognized the data sources. I then published to Tableau Public (Menu → File → Save to Tableau Public).

Click through to view the dashboard on Tableau Public

You can click through the image to explore the finished dashboard (best viewed on a desktop).

What’s next

This dashboard was made with open data. Anyone with a Mapbox account and Tableau Public can replicate the project and extend it to their needs. For example, healthcare providers could use this tool to identify in-network and out-of-network facilities and allocate resources in a way that maximizes accessibility for patients. Although the dashboard shows the population counts for the United States, it’s entirely possible to scale this to the whole world.

Learn more about our tools for data viz, and follow the tag Business Intelligence for Part II of the series. Reach out to our team when you’re ready to roll out a solution to your customers.

Allan Walker


Build a dashboard for healthcare resource planning — Part I was originally published in Points of interest on Medium, where people are continuing the conversation by highlighting and responding to this story.


Viewing all articles
Browse latest Browse all 2230

Trending Articles