Difference between revisions of "Griffins Proposal"

From Analytics Practicum
Jump to navigation Jump to search
 
(6 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
|-
 
|-
 
! style="width: 25%; height: 50px; background-color:#0081a1"| [[AY1516_T2_Griffins | <span style="color:#ffffff; font-size:17px; ">Home</span>]]
 
! style="width: 25%; height: 50px; background-color:#0081a1"| [[AY1516_T2_Griffins | <span style="color:#ffffff; font-size:17px; ">Home</span>]]
! style="width: 25%; background-color:#ff8819"| [[Griffins_Proposal | <span style="color:#ffffff; font-size:17px;">Project Proposal</span>]]
+
! style="width: 25%; background-color:#ff8819"| [[Griffins_Proposal | <span style="color:#ffffff; font-size:17px;">Project Report</span>]]
 
! style="width: 25%; background-color:#0081a1"| [[Griffins_Project_Management | <span style="color:#ffffff; font-size:17px;">Project Management</span>]]
 
! style="width: 25%; background-color:#0081a1"| [[Griffins_Project_Management | <span style="color:#ffffff; font-size:17px;">Project Management</span>]]
 
! style="width: 25%; background-color:#0081a1"| [[Griffins_Deliverable| <span style="color:#ffffff; font-size:17px;">Deliverables</span>]]
 
! style="width: 25%; background-color:#0081a1"| [[Griffins_Deliverable| <span style="color:#ffffff; font-size:17px;">Deliverables</span>]]
Line 8: Line 8:
 
<br>
 
<br>
  
<div style="background: #0081a1; padding: 5px; font-weight: bold; line-height: 1em; text-indent: 15px; border-left: #FF8819 solid 32px; font-size: 16px"><font color="#fff">Proposal</font></div>
+
<div style="background: #0081a1; padding: 5px; font-weight: bold; line-height: 1em; text-indent: 15px; border-left: #FF8819 solid 32px; font-size: 16px"><font color="#fff">Final Report</font></div>
[https://www.dropbox.com/s/2p7pwt9s9x2ab8d/AP_Team12_Griffins_InterimProposal.pdf?dl=0 Proposal]
+
[[Media:AP_Team12_Griffins_Research_paper.pdf|Final Report and Poster]]
 +
<br>
 +
[[Media:Poster-griffin.jpg|Poster]]
 
<br><br>
 
<br><br>
 
<div style="background: #0081a1; padding: 5px; font-weight: bold; line-height: 1em; text-indent: 15px; border-left: #FF8819 solid 32px; font-size: 16px"><font color="#fff">Overview</font></div>
 
<div style="background: #0081a1; padding: 5px; font-weight: bold; line-height: 1em; text-indent: 15px; border-left: #FF8819 solid 32px; font-size: 16px"><font color="#fff">Overview</font></div>
The Health Promotion Board (HPB) was established as a statutory board under the Ministry of Health in 2001 with a vision to build a nation of healthy people. HPB organises many Health Promotion programmes and requires many tools to assist them in planning to ensure efficient outreach and maximize public resources.
+
The Health Promotion Board (HPB) was established as a statutory board under the Ministry of Health in 2001 with a vision to build a nation of healthy people. HPB organises many Health Promotion programmes and requires many tools to assist them in planning to ensure efficient outreach and maximize public resources. HPB is also tasked under the Healthy Living Master Plan, to enable Singaporeans to have access to healthy living at the “doorstep” of every home, workplace and school, by 2020.
 +
<br><br>
  
 +
<div style="background: #0081a1; padding: 5px; font-weight: bold; line-height: 1em; text-indent: 15px; border-left: #FF8819 solid 32px; font-size: 16px"><font color="#fff">Motivation</font></div>
 +
Currently, the process to calculate the accessibility of healthy living amenities at HPB is highly manual. The HPB staff are required to do perform analysis within selected areas for their outreach programmes, and this is largely done on excel spreadsheets. In addition, new colleagues typically have difficulties picking up technical skills related to GIS (such as using QGIS), and hence, are very reliant on a small group of staff that with the technical skills, to perform geospatial queries.
 
<br><br>
 
<br><br>
<div style="background: #0081a1; padding: 5px; font-weight: bold; line-height: 1em; text-indent: 15px; border-left: #FF8819 solid 32px; font-size: 16px"><font color="#fff">Motivation</font></div>
 
The current process at HPB is manually intensive, as staff are required to do perform analysis in selecting suitable areas for their outreach programmes, and this is largely done by calculating their KPI on excel spreadsheets. In addition, new colleagues typically have difficulties picking up technical skills related to GIS (such as using QGIS), and hence, are very reliant on a small group of staff that with the technical skills.
 
  
<br><br>
 
 
<div style="background: #0081a1; padding: 5px; font-weight: bold; line-height: 1em; text-indent: 15px; border-left: #FF8819 solid 32px; font-size: 16px"><font color="#fff">Objectives</font></div>
 
<div style="background: #0081a1; padding: 5px; font-weight: bold; line-height: 1em; text-indent: 15px; border-left: #FF8819 solid 32px; font-size: 16px"><font color="#fff">Objectives</font></div>
Our project aims to provide a custom GIS platform that will reduce manual data entry, is easy to use, and will enable the staff to gain greater insights into the data they currently possess.  
+
Our project aims to provide a custom GIS platform, named Healthy360, that will reduce manual data entry, is easy to use, and will enable the staff to gain greater insights into the data they currently possess.  
  
This platform will be in the form of an interactive and visual web application that utilises GIS functions for geospatial planning and analysis.  
+
Healthy360 will be in the form of an interactive and visual web application that utilises GIS functions for geospatial planning and analysis and will allow the user to do the following:
 +
 +
# Check HPB’s KPI, i.e. obtain the percentage of dwelling units that has access to x number of amenities at x buffer distance
 +
# Obtain the number of amenities surrounding each HDB block at a set buffer distance or at varying distance for each amenity
 +
# Identify HDB blocks that are classified under high, medium and low risk
  
The web application will compute and analyse HPB KPI reporting metrics - i.e. the percentage of HDB blocks that meet the user-defined criterion. Based on the criteria set by the user, the HDB blocks will be grouped into high, medium and low risk. We also aim to provide HDB with the option of viewing data by planning area, to allow HPB to analyse the spread of the high, medium and low risks of HDB blocks at a bigger scale.  
+
These functions aim to allow HPB staff to identify blocks with limited accessibility and plan for more healthy living amenities in the vicinity.  
 +
<br><br>
  
<br><br>
+
<div style="background: #0081a1; padding: 5px; font-weight: bold; line-height: 1em; text-indent: 15px; border-left: #FF8819 solid 32px; font-size: 16px"><font color="#fff">Literature Review</font></div>
<div style="background: #0081a1; padding: 5px; font-weight: bold; line-height: 1em; text-indent: 15px; border-left: #FF8819 solid 32px; font-size: 16px"><font color="#fff">Scope of Work</font></div>
+
The concept of measuring accessibility of amenities from specified points has been explored is various projects.  
Our scope of work includes building a web application that would run on a SVY21 projection.
 
<br><br>
 
<u>Visualisation</u><br>
 
One of the key visualisation feature is allowing users to toggle, view and overlay map layers, on top of base layers from OpenStreetMap (OSM). Attributes of each location can be displayed on mouseover and users may customise the colours used to represent pointers on different map layers according to their own preferences.
 
  
[[File:Scopeofwork1.png|500px|frameless|center|Pop-up box to display details of each point, a side bar to toggle base map and different map layers and a search box to search for addresses or postal codes]]
+
One of the past projects done by SMU Geospatial Analytics students is highly similar to Healthy360. The application by Team Blank seeks to identify service gaps in the planning area of Bedok. Users can choose a particular service and select the buffer distance. The application will then output the number of blocks located within the selected buffer distance of the amenity selected. If more than one amenity is selected, the application will classify blocks that are located within the buffer of both amenities to be “Best Match” and the rest to be “Good Match”.
<small><center><i>Pop-up box to display details of each point, a side bar to toggle base map and different map layers and a search box to search for addresses or postal codes</i></center></small><br>
 
  
The function to upload a GEOJson or KML would be included, to allow users to plot their own map layers, and introduce new amenities into the analysis.  
+
However, calculations to check for the number of blocks are not done on the fly. Instead, it is pre-calculated and saved as an attribute in the .js layers. Healthy360o aims to improve on this application and adopt on-the-fly calculations. This will provide the user with the flexibility to change .js layers and still be able to obtain an output. In addition, performing the calculations on-the-fly will mean a more lightweight application.
  
[[File:Scopeofwork2.png|500px|frameless|center|Icon at the top left corner allows user to upload new layers and name it ]]
+
[[File:lit-review-teamblank.png|700px|center|Team Blank’s application: 200m buffers around bus stops and libraries]]
<small><center><i>Icon at the top left corner allows user to upload new layers and name it </i>
+
<center><small>''[https://wiki.smu.edu.sg/1415T2is415/Team_Blank_Project_Application Team Blank’s application]: 200m buffers around bus stops and libraries''</small></center>
</center></small>
 
 
<br>
 
<br>
[[File:Scopeofwork3.png|500px|frameless|center|New layer will be displayed and the sidebar will be updated accordingly]]
 
<small><center><i>New layer will be displayed and the sidebar will be updated accordingly
 
</i></center></small>
 
  
<u>KPI Calculations</u><br>
+
Another application done by a SMU Geospatial Analytics student, Sim Jing Xiang, contains functions that is similar to Healthy360o as well. His application seeks to help property developers identify areas to build new properties like shopping centre. The application allows the user to select a service type, shopping mall or library, and a buffer distance. A buffer is then set from the centroid of every planning area, and the number of services that falls within the buffer is calculated. The more services the buffered area has, the darker the colour of the buffer. Although this application performs the calculation on the fly, creating the buffer from the centroid of each planning area is not ideal. This is because the central region of Singapore has planning areas that smaller sized, whereas areas in the north and the west have huge planning areas. As a result, the distribution of the buffer circles are not even, and locations in the central area tend to have higher density of amenities. Healthy360o aims to make improvements by buffering from individual HDB blocks instead.
To allow users to calculate the KPI, a form would be required to allow users to input the buffer radius and type of amenities to search for within the radius. Based on the number of amenities that falls within the user-defined buffer area, the HDB blocks will be classified into high risk, medium risk, and low risk blocks.  
+
 
 +
[[File:lit-review-simapp.png|700px|center|Sim Jing Xiang’s application: 2.4km buffers to identify areas with high density of libraries]]
 +
<center><small>''[https://wiki.smu.edu.sg/1516t2is415g1/IS415_2015-16_Term2_Assign1_Sim_Jing_Xiang#Application  Sim Jing Xiang’s application:]: 2.4km buffers to identify areas with high density of libraries''</small></center>
 +
<br>
  
<p>HPB currently have 3 priority areas and HDB block’s risk level is determined by the number of priority areas, whose criteria were met. </p>
 
  
[[File:Scopeofwork4.png|500px|frameless|center]]
+
<div style="background: #0081a1; padding: 5px; font-weight: bold; line-height: 1em; text-indent: 15px; border-left: #FF8819 solid 32px; font-size: 16px"><font color="#fff">Data</font></div>
<i><small><center>
+
All datasets used in Healthy360o are obtained from HPB and data.gov.sg, and can be assumed to be valid and accurate. Healthy360o contains the following point layers and polygon layers
High risk – HDB blocks that do not meet any of the criteria <br>
+
<br>
Moderate risk – HDB blocks that meet 1 of the criteria (any 1 of the 3)<br>
+
Point layers
Low risk – HDB blocks that meet 2 of the criteria (any 2 of the 3)
+
* Healthier dining options (Restaurants, Fast food, Coffeeshop, Foodcourt)
</center></small></i>
+
* Smoking Cessation Areas
 +
* National Parks
 +
* Malls with physical activities
 +
* HDB Blocks
 +
Polygon layers
 +
* Choropleth map of HDB blocks by planning area
 +
* Choropleth map of dwelling units by planning area
 +
<br>
 +
The point layers’ datasets came in the form of .csv with only postal codes. To obtain the spatial coordinates, the postal codes were geocoded using OneMap API, and the xy coordinates under the SVY21 projection were retrieved. The coordinates could be retrieved from all the postal codes with the exception of 1 HDB building. The .csv files were then exported as .shp files using QGIS, with xy coordinates projected to wgs4326, to allow for distance calculation at a later stage.
  
The different risk levels will be visualised in the form of a choropleth map, grouped by planning area as well. This can allow the staff to identify planning areas with greater density of high blocks, or planning areas with higher concentration of low risk blocks. For the staff to further gain insights, tables and charts can generated to reveal the number of amenities within the planning area, highlighting amenities that is severely lacking, or over supplied.
+
[[File:QGIS-coords-function.png|700px|center|Exporting the coordinates of the points using QGIS in-built functions]]
 +
<center><small>''Exporting the coordinates of the points using QGIS in-built functions''</small></center>
 +
<br>
  
[[File:Scopeofwork5.png|500px|frameless|center|Choropleth map by planning area]]
+
Using QGIS, the styling of the layers were also edited, to reduce the hassle of coding it from scratch. The link to the layer’s markers and pop-up box content are added as new attributes, under the column “icon_exp” and “html_exp” respectively.  
<small><center><i>Choropleth map by planning area
 
</i></center></small><br>
 
  
<div style="background: #0081a1; padding: 5px; font-weight: bold; line-height: 1em; text-indent: 15px; border-left: #FF8819 solid 32px; font-size: 16px"><font color="#fff">Data</font></div>
+
The HDB point dataset provided by HPB contains the planning area which it falls within. This is used to calculate the number of dwelling units and blocks of each planning area using pivot table in excel. This data is then matched to the planning area polygon .shp file in QGIS. A choropleth map is then generated under the jenks method.
The following datasets would be required for this project
 
*Living dwellings (List of HDB Blocks and number of dwelling units per block)
 
*Healthier dining options(Restaurants, Fast Food Food Court, Coffeeshop)
 
*Sundays at the Park
 
*Physical Activity Malls
 
*Smoking Cessation Touchpoints
 
*GRC zones
 
  
The above datasets would all be represented in point form, with the exception of the GRC zones.  
+
The QGIS2Leaflet package was then applied from QGIS to output the layers in .js format.  
  
<p>Datasets would have to be converted to .shp or geoJSON and JSON formats. Shapefiles would allow us to explore the data on QGIS while geoJSON and JSON formats allow integration with javascript libraries like leaflet.js and d3.js.</p>
+
[[File:Data-js.png|900px|center|Sample of js file]]
 +
<center><small>''Sample of js file''</small></center>
 
<br>
 
<br>
<big>Examples of Data</big><br>
 
Healthier Dining.json
 
The original dataset for healthier dining was in csv format. It was geocoded and uploaded on QGIS, before being converted to geoJSON format using the QGIS2Leaflet plugin, to allow leaflet.js to display the map on the front end.
 
  
[[File:data1.png|500px|frameless|center]]
+
<div style="background: #0081a1; padding: 5px; font-weight: bold; line-height: 1em; text-indent: 15px; border-left: #FF8819 solid 32px; font-size: 16px"><font color="#fff">Features and Methodology</font></div>
 +
<p>
 +
<div style="background: #FF8819; padding: 4px; font-weight: bold; line-height: 1em; text-indent: 15px; font-size: 14px"><font color="#fff">Feature 1: Calculate number and percentage of units with access to amenities</font></div>
 +
 
 +
HPB requires an application that allows the user to set the minimum number of amenity needed within a set distance from the HDB. The user will be allowed to vary the minimum number and distance for each amenity. The application will then check if the conditions is met for every HDB block, and return the number and percentage of HDB blocks and the dwelling units (within each HDB block), that meets the criteria set.
 +
 
 +
Healthy360 provides the interface to do the above. Users are able to select from a dropdown list, the minimum number of amenities needed within a fixed buffer distance.
 +
[[File:criteria-setting.png|500px|frameless|center|Pop-up window for user to set criteria for calculating the KPI]]
 +
 
 +
On backend, without a localhost, all calculations are done on the fly. The application loops through each individual HDB Block in the .js file, and for each individual block, it loops through each type of the amenity, and each of the point from each amenity type. Each individual point is retrieved from the .js using .eachlayer, a leaflet.js function. 
 +
 
 +
It then computes the distance between each point to each HDB block, and compares the distance to the user’s selection. Distance is calculated using .distanceTo, another leaflet.js function. If it is smaller or equals to the distance selected, it adds one to counter of that amenity type, and loops until all the points have been exhausted.
 +
 
 +
For healthier dining options, it is slightly more complex, for it has three types of dining amenities, restaurant or fast food, food court and coffeeshop, under the same layer, i.e. within the same js file. When checking for healthier dining options, an additional check is placed at the end to check if the type of healthier dining matches the user’s selection, before adding one to the counter.
 +
 
 +
[[File:Kpi-codes.png|900px|center|Function that iterates through every point in the HDB layer, and then subsequently every point in healthier dining layer]]
 +
<center><small>''Function that iterates through every point in the HDB layer, and then subsequently every point in healthier dining layer''</small></center>
 
<br>
 
<br>
<center>Parks.json</center>
+
 
[[File:data2.png|500px|frameless|center]]
+
The counter for each individual amenity is then compared to the user's selection, if it is greater than or equal to what the user chose, the number of dwelling units in that HDB block would be added to the counter for total dwelling units.  
 +
 
 +
[[File:Kpi-counter-codes.png|700px|center|if else condition to check which amenities’ conditions are met]]
 +
<center><small>''if else condition to check which amenities’ conditions are met''</small></center>
 
<br>
 
<br>
[[File:data3.png|500px|frameless|center]]
 
<small><center><i>Parks and Healthier dining options displayed on QGIS
 
</i></center></small>
 
  
<br><br>
+
After looping through all the HDB blocks, the number stored in the dwelling units counter would be divided by the total number of dwelling units and a percentage will be returned to the user. A .csv file of the blocks that fulfils the criteria set can also be generated and downloaded.  
<div style="background: #0081a1; padding: 5px; font-weight: bold; line-height: 1em; text-indent: 15px; border-left: #FF8819 solid 32px; font-size: 16px"><font color="#fff">Methodology</font></div>
 
Before building the web application, we have to first process the data obtained. Datasets are in the form of .csv, and most of the datasets only have postal codes for locational details. These datasets will be geocoded using the OneMap API.  
 
  
<p>The geocoded data will be plotted on QGIS. Within QGIS, a plugin, QGIS2Leaflet, would then be used to generate a basic javascript web application, and the layers are saved in json format. </p>
+
[[File:KPI-display.png|900px|center|Number and percentage of the households are displayed on the sidebar. User can specify the name of the .csv file to be download]]
 +
<center><small>''Number and percentage of the households are displayed on the sidebar. User can specify the name of the .csv file to be download''</small></center>
 +
<br>
  
<p>With the basic application in place, Bootstrap will be used to construct input fields for the user to select the relevant layers and the buffer distance for each of the layers. The user will also be able to key in the criteria that has to be met by each block, I.e. How many points from each layer should a buffer around each block contain. </p>
+
[[File:Csv-sample.png|900px|center|Sample of CSV file, data here is merely a mock sample due to confidentiality of the data]]
 +
<center><small>''Sample of CSV file, data here is merely a mock sample due to confidentiality of the data''</small></center>
 +
<br>  
  
[[File:methodology1.png|500px|frameless|center|A prototype of how the input list will look like]]
+
<div style="background: #FF8819; padding: 4px; font-weight: bold; line-height: 1em; text-indent: 15px; font-size: 14px"><font color="#fff">Feature 2: Identify number of amenities around a single HDB block </font></div>
<small><center><i>A prototype of how the input list will look like</i></center></small>
 
  
<p>The web application would then buffer around each individual HDB block and calculate the number of points, of each amenity, that falls within the buffer. This data would be store in geoJSON format for now.</p>
+
This feature allows the user to search for an address, done using GoogleMaps API, set the buffer distance and query for the number of amenities around it. Healthy360 allows users to drag the marker as well, should GoogleMaps be unable to return a result or if they are unsure of the address.  
  
<p>The KPI currently used by HPB looks at the percentage of dwelling units that meets the criteria set by the user. We would then need to compare the number of each amenity found in the buffer, to the criteria keyed in by the user. On backend, this process, will be iterated through each HDB block. The amenities that meets or fails the criteria will be record as TRUE/FALSE on backend. </p>
+
The user also has the option to set a standard buffer distance for all the amenities, or vary the distance per amenity.  
  
<p>After iterating through all the HDB blocks, the HDB blocks that meet the criteria set will be retrieved and dwelling of these HDB blocks, will be summed up and divided against the total number of dwelling units in Singapore to obtain the percentage. </p>
+
[[File:Block-buffer.png|900px|center|Search box for address is located on the sidebar. Dropdown list located just below it allows user to set a fixed buffer distance for all amenities, and this is reflected on the map as a red buffer zone. Else, users can click on "Modify Individual Buffer Distance" to set varying buffer distances for each amenity]]
 +
<center><small>''Search box for address is located on the sidebar. Dropdown list located just below it allows user to set a fixed buffer distance for all amenities, and this is reflected on the map as a red buffer zone. Else, users can click on "Modify Individual Buffer Distance" to set varying buffer distances for each amenity. The results are then displayed on the side bar as well''</small></center>
 +
<br>
  
<p>The process to classify the HDB blocks under high, medium or low risk follows a similar process. But instead of only considering the amenities selected by the user, all amenities under the three priority area will be used. Each HDB block will be checked by priority area and likewise, boolean will be used to record whether criteria(s) in each priority area is met. The number of priority areas with criteria(s) met, will be summed and classified into the different risk levels accordingly. </p>
+
[[File:Block-buffer-criteria.png|500px|center|Pop up box when user clicks on "Modify Individual Buffer Distance]]
 +
<center><small>''Pop up box when user clicks on "Modify Individual Buffer Distance''</small></center>
 +
<br>
  
<p>Users can then select the risk level and generate the choropleth map. Grouped bar charts can also be used to display the number of amenities in each planning area, or the number of HDB blocks, of the 3 categories, in each planning area, to provide a macro view for the user. </p>
+
Once selected, the application loads the amenities’ layers on backend and loops through each point. The distance between the point and the selected HDB block is then calculated and compared to the user’s selection. This process is the same as the KPI calculation.
 +
<br><br>
 +
<div style="background: #FF8819; padding: 4px; font-weight: bold; line-height: 1em; text-indent: 15px; font-size: 14px"><font color="#fff">Feature 3: Identifying and displaying risk levels of the HDB blocks </font></div>
 +
In categorising the risk level of the HDB blocks, HPB has set a criteria that observes 3 categories.  
  
 +
*Obesity: Nutrition (Healthier dining options)
 +
**Restaurants or fastfood
 +
**Food court
 +
**Coffeshops
 +
*Obesity: Physical Activity
 +
**Health promoting malls
 +
**Sundays at the park
 +
*Tobacco Control
 +
**Smoking cessation areas
  
[[File:methodology2.png|500px|frameless|center|Prototype of choropleth map based on risk level selected]]
+
A HDB block is classified under low risk, if fulfils the conditions set in 2 of the 3 categories. It is classified under medium risk, if it fulfils the conditions set in 1 of the 3 categories. It is classified under high risk, if it does not fulfil any of the conditions set in all the categories.
<small><center><i>Prototype of choropleth map based on risk level selected</i></center></small>
 
  
<p>New layers can be added on the fly to display on the map for users to add to their analysis computation. This is done using leaflet’s fileLayerLoad plugin. Users can upload their file and sidebar to toggle layers, as well as the the list of layers available for the user to calculate the KPI, will be updated accordingly. </p>
+
This function is linked with the KPI calculation function in the web application. The conditions for each layer is taken to be the same conditions used to calculate the KPI, i.e. the minimum number of amenities that should exist within the selected buffer distance. As long as at least one layer from each category is selected, the risk level will be computed at the end of each loop through the HDB layer. A geojson object is then created and plotted to the map. Each HDB point is a single geojson object.  
  
<p>The data in the json files for the default layers can also be updated as needed. </p>
+
[[File:Risk-map-criteria.png|900px|center|Risk level of HDB blocks visualised on the map. The number of each amenity is displayed in the pop up as well, to give users a better understanding of why this block is classified as low risk. ]]
 +
<center><small>''Risk level of HDB blocks visualised on the map. The number of each amenity is displayed in the pop up as well, to give users a better understanding of why this block is classified as low risk.''</small></center>
 +
<br>
 +
[[File:Risk-code.png|900px|center|Code to calculate the risk of the HDB and plot it on the map is inserted within the KPI feature function, at the end of the loop through each HDB block]]
 +
<center><small>''Code to calculate the risk of the HDB and plot it on the map is inserted within the KPI feature function, at the end of the loop through each HDB block''</small></center>
 +
<br>
 +
<br>
 +
<div style="background: #0081a1; padding: 5px; font-weight: bold; line-height: 1em; text-indent: 15px; border-left: #FF8819 solid 32px; font-size: 16px"><font color="#fff">Process Map</font></div>
 +
<br>
 +
[[File:processmap.png|900px|center|Code to calculate the risk of the HDB and plot it on the map is inserted within the KPI feature function, at the end of the loop through each HDB block]]
  
<p>To further aid visualization of the data, d3.js will be used to generate and display data in the form of charts and graphs. </p>
 
  
<br>
 
 
<div style="background: #0081a1; padding: 5px; font-weight: bold; line-height: 1em; text-indent: 15px; border-left: #FF8819 solid 32px; font-size: 16px"><font color="#fff">Technologies</font></div>
 
<div style="background: #0081a1; padding: 5px; font-weight: bold; line-height: 1em; text-indent: 15px; border-left: #FF8819 solid 32px; font-size: 16px"><font color="#fff">Technologies</font></div>
 +
[[File:system-architecture.png|900px|center|Code to calculate the risk of the HDB and plot it on the map is inserted within the KPI feature function, at the end of the loop through each HDB block]]
 +
 +
 
{| class="wikitable"
 
{| class="wikitable"
 
! style="font-weight: bold;" | Technology
 
! style="font-weight: bold;" | Technology
Line 145: Line 186:
 
|A free and open sourced geographic information system to create, edit, visualise, analyse and edit geospatial information.   
 
|A free and open sourced geographic information system to create, edit, visualise, analyse and edit geospatial information.   
 
|}
 
|}
 
+
<br>
 +
<div style="background: #0081a1; padding: 5px; font-weight: bold; line-height: 1em; text-indent: 15px; border-left: #FF8819 solid 32px; font-size: 16px"><font color="#fff">Areas of further development</font></div><br>
 +
<b>Composite value in calculating risk levels</b><br>
 +
In calculating the risk levels of the HDB flats, a more comprehensive method can also be developed. Different weightage can be given to each amenity, depending on its importance to providing healthy living standards. For instance, parks and gyms can be given a weight of 0.9 (out of 1) while fruit stalls or smoking cessation points can be given a lower score of 0.6. The scores can then be added up and compared against a benchmark, to rate the risk level of each HDB flat.
 
<br><br>
 
<br><br>
<div style="background: #0081a1; padding: 5px; font-weight: bold; line-height: 1em; text-indent: 15px; border-left: #FF8819 solid 32px; font-size: 16px"><font color="#fff">Deliverables</font></div>
+
<b>Other uses</b><br>
A lightweight, portable web application that can be easily brought over to different machines without installation. The interactive web application should show the Singapore map with many attributes for filtering to assist in HPB’s daily planning needs. The user would be able to use the web application for presentations and also export the generated results into various file formats.
+
Currently, the scope of the project is limited to HDB blocks (i.e. public housing). But given the address search bar and draggable marker, the functionalities of Healthy360o can be extended to private housing and even business units. Entrepreneurs looking to set up a salad shop or heathlier dining restaurant, can use Healthy360o to check for areas of high risk and seek to set up a shop in the vicnity.  
 
 
<div style="background: #0081a1; padding: 5px; font-weight: bold; line-height: 1em; text-indent: 15px; border-left: #FF8819 solid 32px; font-size: 16px"><font color="#fff">Limitations</font></div>
 
We have to make the application portable and usable without any installation of programs due to the policy restrictions of our clients. In addition, the database cannot be hosted online due to the confidentiality of data which eliminates the use of Structured Query Language (SQL). The dataset will be kept in local drives and the queries must be done on the fly without the usage of database and SQL queries.
 
 
 
<p>This leads to further difficulties in computing the KPI without a space to store, query and retrieve the data necessary to compute the KPI. This problem is also further complicated by the option to allow user to upload new layers and set different criterion.  </p>
 
  
<p>In working around this limitation, we have explored the option of a portable database, Spatialite, and am currently trying out javascript libraries like, turf.js. </p>
+
The application can also be used to identify areas are higher crime rates, by replacing the data layers with data layers of crime. The relevant authorities can then use the data to send more police patrol to the area.

Latest revision as of 14:20, 16 April 2016

Home Project Report Project Management Deliverables


Final Report

Final Report and Poster
Poster

Overview

The Health Promotion Board (HPB) was established as a statutory board under the Ministry of Health in 2001 with a vision to build a nation of healthy people. HPB organises many Health Promotion programmes and requires many tools to assist them in planning to ensure efficient outreach and maximize public resources. HPB is also tasked under the Healthy Living Master Plan, to enable Singaporeans to have access to healthy living at the “doorstep” of every home, workplace and school, by 2020.

Motivation

Currently, the process to calculate the accessibility of healthy living amenities at HPB is highly manual. The HPB staff are required to do perform analysis within selected areas for their outreach programmes, and this is largely done on excel spreadsheets. In addition, new colleagues typically have difficulties picking up technical skills related to GIS (such as using QGIS), and hence, are very reliant on a small group of staff that with the technical skills, to perform geospatial queries.

Objectives

Our project aims to provide a custom GIS platform, named Healthy360, that will reduce manual data entry, is easy to use, and will enable the staff to gain greater insights into the data they currently possess.

Healthy360 will be in the form of an interactive and visual web application that utilises GIS functions for geospatial planning and analysis and will allow the user to do the following:

  1. Check HPB’s KPI, i.e. obtain the percentage of dwelling units that has access to x number of amenities at x buffer distance
  2. Obtain the number of amenities surrounding each HDB block at a set buffer distance or at varying distance for each amenity
  3. Identify HDB blocks that are classified under high, medium and low risk

These functions aim to allow HPB staff to identify blocks with limited accessibility and plan for more healthy living amenities in the vicinity.

Literature Review

The concept of measuring accessibility of amenities from specified points has been explored is various projects.

One of the past projects done by SMU Geospatial Analytics students is highly similar to Healthy360. The application by Team Blank seeks to identify service gaps in the planning area of Bedok. Users can choose a particular service and select the buffer distance. The application will then output the number of blocks located within the selected buffer distance of the amenity selected. If more than one amenity is selected, the application will classify blocks that are located within the buffer of both amenities to be “Best Match” and the rest to be “Good Match”.

However, calculations to check for the number of blocks are not done on the fly. Instead, it is pre-calculated and saved as an attribute in the .js layers. Healthy360o aims to improve on this application and adopt on-the-fly calculations. This will provide the user with the flexibility to change .js layers and still be able to obtain an output. In addition, performing the calculations on-the-fly will mean a more lightweight application.

Team Blank’s application: 200m buffers around bus stops and libraries
Team Blank’s application: 200m buffers around bus stops and libraries


Another application done by a SMU Geospatial Analytics student, Sim Jing Xiang, contains functions that is similar to Healthy360o as well. His application seeks to help property developers identify areas to build new properties like shopping centre. The application allows the user to select a service type, shopping mall or library, and a buffer distance. A buffer is then set from the centroid of every planning area, and the number of services that falls within the buffer is calculated. The more services the buffered area has, the darker the colour of the buffer. Although this application performs the calculation on the fly, creating the buffer from the centroid of each planning area is not ideal. This is because the central region of Singapore has planning areas that smaller sized, whereas areas in the north and the west have huge planning areas. As a result, the distribution of the buffer circles are not even, and locations in the central area tend to have higher density of amenities. Healthy360o aims to make improvements by buffering from individual HDB blocks instead.

Sim Jing Xiang’s application: 2.4km buffers to identify areas with high density of libraries
Sim Jing Xiang’s application:: 2.4km buffers to identify areas with high density of libraries



Data

All datasets used in Healthy360o are obtained from HPB and data.gov.sg, and can be assumed to be valid and accurate. Healthy360o contains the following point layers and polygon layers
Point layers

  • Healthier dining options (Restaurants, Fast food, Coffeeshop, Foodcourt)
  • Smoking Cessation Areas
  • National Parks
  • Malls with physical activities
  • HDB Blocks

Polygon layers

  • Choropleth map of HDB blocks by planning area
  • Choropleth map of dwelling units by planning area


The point layers’ datasets came in the form of .csv with only postal codes. To obtain the spatial coordinates, the postal codes were geocoded using OneMap API, and the xy coordinates under the SVY21 projection were retrieved. The coordinates could be retrieved from all the postal codes with the exception of 1 HDB building. The .csv files were then exported as .shp files using QGIS, with xy coordinates projected to wgs4326, to allow for distance calculation at a later stage.

Exporting the coordinates of the points using QGIS in-built functions
Exporting the coordinates of the points using QGIS in-built functions


Using QGIS, the styling of the layers were also edited, to reduce the hassle of coding it from scratch. The link to the layer’s markers and pop-up box content are added as new attributes, under the column “icon_exp” and “html_exp” respectively.

The HDB point dataset provided by HPB contains the planning area which it falls within. This is used to calculate the number of dwelling units and blocks of each planning area using pivot table in excel. This data is then matched to the planning area polygon .shp file in QGIS. A choropleth map is then generated under the jenks method.

The QGIS2Leaflet package was then applied from QGIS to output the layers in .js format.

Sample of js file
Sample of js file


Features and Methodology

Feature 1: Calculate number and percentage of units with access to amenities

HPB requires an application that allows the user to set the minimum number of amenity needed within a set distance from the HDB. The user will be allowed to vary the minimum number and distance for each amenity. The application will then check if the conditions is met for every HDB block, and return the number and percentage of HDB blocks and the dwelling units (within each HDB block), that meets the criteria set.

Healthy360 provides the interface to do the above. Users are able to select from a dropdown list, the minimum number of amenities needed within a fixed buffer distance.

Pop-up window for user to set criteria for calculating the KPI

On backend, without a localhost, all calculations are done on the fly. The application loops through each individual HDB Block in the .js file, and for each individual block, it loops through each type of the amenity, and each of the point from each amenity type. Each individual point is retrieved from the .js using .eachlayer, a leaflet.js function.

It then computes the distance between each point to each HDB block, and compares the distance to the user’s selection. Distance is calculated using .distanceTo, another leaflet.js function. If it is smaller or equals to the distance selected, it adds one to counter of that amenity type, and loops until all the points have been exhausted.

For healthier dining options, it is slightly more complex, for it has three types of dining amenities, restaurant or fast food, food court and coffeeshop, under the same layer, i.e. within the same js file. When checking for healthier dining options, an additional check is placed at the end to check if the type of healthier dining matches the user’s selection, before adding one to the counter.

Function that iterates through every point in the HDB layer, and then subsequently every point in healthier dining layer
Function that iterates through every point in the HDB layer, and then subsequently every point in healthier dining layer


The counter for each individual amenity is then compared to the user's selection, if it is greater than or equal to what the user chose, the number of dwelling units in that HDB block would be added to the counter for total dwelling units.

if else condition to check which amenities’ conditions are met
if else condition to check which amenities’ conditions are met


After looping through all the HDB blocks, the number stored in the dwelling units counter would be divided by the total number of dwelling units and a percentage will be returned to the user. A .csv file of the blocks that fulfils the criteria set can also be generated and downloaded.

Number and percentage of the households are displayed on the sidebar. User can specify the name of the .csv file to be download
Number and percentage of the households are displayed on the sidebar. User can specify the name of the .csv file to be download


Sample of CSV file, data here is merely a mock sample due to confidentiality of the data
Sample of CSV file, data here is merely a mock sample due to confidentiality of the data


Feature 2: Identify number of amenities around a single HDB block

This feature allows the user to search for an address, done using GoogleMaps API, set the buffer distance and query for the number of amenities around it. Healthy360 allows users to drag the marker as well, should GoogleMaps be unable to return a result or if they are unsure of the address.

The user also has the option to set a standard buffer distance for all the amenities, or vary the distance per amenity.

Search box for address is located on the sidebar. Dropdown list located just below it allows user to set a fixed buffer distance for all amenities, and this is reflected on the map as a red buffer zone. Else, users can click on "Modify Individual Buffer Distance" to set varying buffer distances for each amenity
Search box for address is located on the sidebar. Dropdown list located just below it allows user to set a fixed buffer distance for all amenities, and this is reflected on the map as a red buffer zone. Else, users can click on "Modify Individual Buffer Distance" to set varying buffer distances for each amenity. The results are then displayed on the side bar as well


Pop up box when user clicks on "Modify Individual Buffer Distance
Pop up box when user clicks on "Modify Individual Buffer Distance


Once selected, the application loads the amenities’ layers on backend and loops through each point. The distance between the point and the selected HDB block is then calculated and compared to the user’s selection. This process is the same as the KPI calculation.

Feature 3: Identifying and displaying risk levels of the HDB blocks

In categorising the risk level of the HDB blocks, HPB has set a criteria that observes 3 categories.

  • Obesity: Nutrition (Healthier dining options)
    • Restaurants or fastfood
    • Food court
    • Coffeshops
  • Obesity: Physical Activity
    • Health promoting malls
    • Sundays at the park
  • Tobacco Control
    • Smoking cessation areas

A HDB block is classified under low risk, if fulfils the conditions set in 2 of the 3 categories. It is classified under medium risk, if it fulfils the conditions set in 1 of the 3 categories. It is classified under high risk, if it does not fulfil any of the conditions set in all the categories.

This function is linked with the KPI calculation function in the web application. The conditions for each layer is taken to be the same conditions used to calculate the KPI, i.e. the minimum number of amenities that should exist within the selected buffer distance. As long as at least one layer from each category is selected, the risk level will be computed at the end of each loop through the HDB layer. A geojson object is then created and plotted to the map. Each HDB point is a single geojson object.

Risk level of HDB blocks visualised on the map. The number of each amenity is displayed in the pop up as well, to give users a better understanding of why this block is classified as low risk.
Risk level of HDB blocks visualised on the map. The number of each amenity is displayed in the pop up as well, to give users a better understanding of why this block is classified as low risk.


Code to calculate the risk of the HDB and plot it on the map is inserted within the KPI feature function, at the end of the loop through each HDB block
Code to calculate the risk of the HDB and plot it on the map is inserted within the KPI feature function, at the end of the loop through each HDB block



Process Map


Code to calculate the risk of the HDB and plot it on the map is inserted within the KPI feature function, at the end of the loop through each HDB block


Technologies
Code to calculate the risk of the HDB and plot it on the map is inserted within the KPI feature function, at the end of the loop through each HDB block


Technology Description
Bootstrap An open-source framework for front-end development to add aesthetics to our web application.
D3.js Manipulate data using HTML, SVG, and CSS to allow interaction and animation for our map.
GeoJSON An open standard format designed for construction of simple geographical features with their non-spatial attributes based on JSON.
Leaflet.js An open-source JavaScript library for interactive maps to help us add in the needed interactions.
OpenStreetMap.org A free to use map of the world under an open licence which will be used for our mapping in our web application.
QGIS A free and open sourced geographic information system to create, edit, visualise, analyse and edit geospatial information.


Areas of further development


Composite value in calculating risk levels
In calculating the risk levels of the HDB flats, a more comprehensive method can also be developed. Different weightage can be given to each amenity, depending on its importance to providing healthy living standards. For instance, parks and gyms can be given a weight of 0.9 (out of 1) while fruit stalls or smoking cessation points can be given a lower score of 0.6. The scores can then be added up and compared against a benchmark, to rate the risk level of each HDB flat.

Other uses
Currently, the scope of the project is limited to HDB blocks (i.e. public housing). But given the address search bar and draggable marker, the functionalities of Healthy360o can be extended to private housing and even business units. Entrepreneurs looking to set up a salad shop or heathlier dining restaurant, can use Healthy360o to check for areas of high risk and seek to set up a shop in the vicnity.

The application can also be used to identify areas are higher crime rates, by replacing the data layers with data layers of crime. The relevant authorities can then use the data to send more police patrol to the area.