Difference between revisions of "Hospital Site Suitability Selection using QGIS"

From CUOSGwiki
Jump to navigationJump to search
Line 60: Line 60:
 
In order to be able to perform operations such as buffer and clip for fire halls, public washrooms and hospitals which are currently KMZ files, we need to convert them to shapefiles. To do this, right click the file from the ''Layers Panel'', then select '''Save as'''. In the pop-up window, make sure the Format is ''ESRI Shapefile'', choose where you want to save it and what you want it to be called by selecting the '''Browse''' button and make sure the CRS is Project CRS (EPSG:26910 -NAD83 / UTM zone 10 N) and click '''OK'''. Once the shapefiles have been added, remove the original data files from the project.
 
In order to be able to perform operations such as buffer and clip for fire halls, public washrooms and hospitals which are currently KMZ files, we need to convert them to shapefiles. To do this, right click the file from the ''Layers Panel'', then select '''Save as'''. In the pop-up window, make sure the Format is ''ESRI Shapefile'', choose where you want to save it and what you want it to be called by selecting the '''Browse''' button and make sure the CRS is Project CRS (EPSG:26910 -NAD83 / UTM zone 10 N) and click '''OK'''. Once the shapefiles have been added, remove the original data files from the project.
   
[[File:SaveAsShapefile.PNG|450px|thumb|none|Converting KMZ to shapefile]]
+
[[File:SaveAsShapefile.PNG|300px|thumb|none|Converting KMZ to shapefile]]
   
 
=== Editing Attribute Tables: Selecting by Expression ===
 
=== Editing Attribute Tables: Selecting by Expression ===
Line 85: Line 85:
 
Repeat this with each of the remaining shapefiles using the criteria presented above. The finished result should look something like this:
 
Repeat this with each of the remaining shapefiles using the criteria presented above. The finished result should look something like this:
   
[[File:AllBuffers.PNG|300px|thumb|none|Buffered layers]]
+
[[File:AllBuffers.PNG|400px|thumb|none|Buffered layers]]
   
 
=== Merging Shapefiles (again) ===
 
=== Merging Shapefiles (again) ===
Line 101: Line 101:
 
The final result of all of the processes we have performed should look something like this:
 
The final result of all of the processes we have performed should look something like this:
   
[[File:FinalArea.PNG|300px|thumb|none|Final acceptable areas shapefile]]
+
[[File:FinalArea.PNG|400px|thumb|none|Final acceptable areas shapefile]]
   
 
=== Making a Map ===
 
=== Making a Map ===

Revision as of 15:59, 20 December 2017

Purpose

The purpose of this tutorial is to give users an understanding of what free and open source software (FOSS) is and demonstrate how to use Google Earth and Quantum GIS (QGIS) to manipulate spatial data. This tutorial will demonstrate how to use QGIS for site suitability analysis of a hospital in Vancouver, BC.

Introduction

When it comes to building a new hospital, there are criteria that should be followed in order to find the most appropriate location. Using a geographic information system to determine suitable areas for development allow the user to not only visualize where it is a suitable for a hospital to be located based on a set of rules, but also where it makes the most sense visually. Based on two papers (GIS-Based Multi-Criteria Analysis for Hospital Site Selection in Haidian District of Beijing (2012) and Hospital Site Selection Using Two-Stage Fuzzy Multi-Criteria Decision Making Process (2011)) the criteria for hospital site suitability can be summarized as follows:

Criteria for hospital site selection

Software

The two software packages required for this tutorial are QGIS and Google Earth. To download QGIS, click on this link and choose which version you would like. I would suggest downloading the Long Term Release Repository (most stable) as it is less likely to have any bugs then the latest version. At the time of the production of this tutorial, version 2.14.21 was used. To download Google Earth, click this link and select Agree and Download to agree to Google Maps/Google Earth Additional Terms of Service and download the software package. Once you have downloaded and installed both software packages, you are ready to download the required data for this tutorial.

Data

Create a working folder wherever you would like your files to be saved on your computer and within it place another folder titled Data. This is where you will store all of the needed you need to complete this tutorial. For this project, all of the data required is available at http://data.vancouver.ca/datacatalogue/, except for one KML file which you need to create in Google Earth. From the Vancouver data catalogue, you will need to download the shapefile packages for fire halls, local area boundary, railways, city streets, rapid transit, zoning districts and the KML file for public washrooms. To download a data file, scroll through the catalogue and click on the file name you want to download.

For example, we want to download the Fire halls file, so we click on the Fire halls hyperlink

Then, scroll to the bottom of the newly loaded page and select the file type you want to download (for this tutorial we want shapefiles (SHP), if available or keyhole markup language files (KML) if not).

Select the SHP file hyperlink

Save the file into the folder that you’ve created to store all of your data, and then unzip it by right clicking the zipped folder and selecting Extract All… and then choose to extract it into the folder storing all of the other data files you have downloaded.

Right click the zipped folder and select Extract All

Here is what the folder looks like once all of the data has been downloaded and extracted:

Folder with all downloaded files

The file that is missing from the data catalogue but vital to this tutorial is a file containing the location of all of the existing hospitals in Vancouver. One way to create this KMZ file is to save all of the locations in Google Earth and export them as a KMZ. To do this you have to open Google Earth and search for hospitals in Vancouver, BC.

Results for the search hospitals in Vancouver, BC

Next, click the folder icon below the search results that says “Copy the current search results to My Places” when you hover over it.

Click the highlighted folder icon to move the search results into your My Places folder

Now right click on the folder containing your search results and select Save Place As...

Right click the folder and select Save Place As

Name the file what you would like, make sure the Save as type is Kmz and save it in the folder with your other data.

Save your newly created file

Once you have exported the KMZ file and saved it in your folder with all of the data you previously downloaded, you are ready to start the tutorial.

Tutorial

Now that you have downloaded the software and collected the required data, it is time to begin. Open QGIS, select the new icon (white piece of paper) to start a new project, and save it in your working folder under whatever name you choose (try not to use spaces or funny characters in your file name).

Setting Up the Environment

Vancouver’s data files are projected in UTM Zone 10, NAD83 (CSRS) so that is what you should project your files as. To do this, go to the Project menu, select Project Properties. The Project Properties windows will open. Select CRS from the left hand menu and then toggle on Enable ‘on the fly’ CRS transformation. The CRS that should be selected is NAD83(CSRS) / UTM zone 10N for the Vancouver region. Click Apply and OK.

Setting Projection to NAD83(CSRS) / UTM zone 10N

Importing Data

Once QGIS is launched, go to the Layer menu -> Add Layer -> Add Vector Layer. In the pop-up window, set your source type as File and click the Browse button under the Source header. Browse to where your shapefile is and double-click it or highlight it and select Open. Insert each of the shapefiles you would like to analyze. When inserting the city streets shapefile, make sure to select the non_city_streets, one_way_streets, lanes and public_streets shapefiles from the folder. From the rapid transit folder, you only need to import the rapid_transit_line shapefile. Modify each shapefile to look the way you would like it to by double-clicking the layer from the Layers Panel on the left hand side, then selecting Style from the left hand side of the popup window. Here you can change the symbol type (such as gradient, single symbol, categorized etc), the colour, the size and more. You’ll notice that some of the points in the hospital KMZ you created don’t lie within the Vancouver local area boundary; this is not a problem as later on in this tutorial the non-valid points will be dissolved.

Display of all of the imported layers

Converting KMZ to Shapefile

In order to be able to perform operations such as buffer and clip for fire halls, public washrooms and hospitals which are currently KMZ files, we need to convert them to shapefiles. To do this, right click the file from the Layers Panel, then select Save as. In the pop-up window, make sure the Format is ESRI Shapefile, choose where you want to save it and what you want it to be called by selecting the Browse button and make sure the CRS is Project CRS (EPSG:26910 -NAD83 / UTM zone 10 N) and click OK. Once the shapefiles have been added, remove the original data files from the project.

Converting KMZ to shapefile

Editing Attribute Tables: Selecting by Expression

Because one of our criterion for hospital site selection is that it should be within a certain distance of residential areas, we need to extract residential areas from the zoning districts shapefile. To do this, you must right-click on the zoning_districts layer and select Open Attribute Table. An attribute table of the zoning districts layer will appear and it will have categories of zoning types as well as zone names. Once you have the attribute table open, select Select Features Using an Expression (the icon showing small yellow square with an E). A Select By Expression window will appear, and in the function list, expand the Fields and Values and select Category. Select the all unique button in the bottom right corner beside Load values and a list should appear of the unique values from this attribute. The field values will have the list of different zoning categories that were seen in the attribute table. In the expression box of the select by expression window, when you double click on the CATEGORY from the Fields and Values list, "CATEGORY" will appear. Once that appears, select the equal (=) sign where the available operators are listed. The next step is to select a field value. Because we want residential areas, we need to select multiple zoning categories. The expression should be "CATEGORY" LIKE '%Dwelling%'. This selects all zones where “Dwelling” is in the name. Click the Select button in the bottom right hand corner and then click Close.

Selection Expression

Saving Selected Points (Shapefile)

The selected zones that are now highlighted can be saved as their own shapefile. To do this, right click on the zoning_districts layer and select Save As and a window will appear. In this window, the format that the shapefile should be saved under is "ESRI Shapefile". Click the Browse button to choose where the file will go and give it a name. Toggle on Save only selected features and Add saved file to map and then click OK.

Residential zones shapefile after it has been added to map

Merging Shapefiles

Because we want to perform operations on all of the street shapefiles and all of the railway shapefiles, we need to merge them. To do this, select the Vector menu -> Data Management Tools -> 'Merge Shapefiles to One. Check the Select by layer in the folder box. Under Input files click Browse and select all of the street files you want to merge (all of the ones you have imported into the project previously). Make sure the Add result to map canvas box is checked and click OK and then Close when the operation is finished processing. Repeat this to merge the rapid transit and railways shapefiles and then remove all of the street and railways files you had imported earlier in the tutorial.

The merged street types and railways types

Buffering Files

Now we need to buffer each of the shapefiles in order to make them meet the criteria for hospital site selection. To do this go to the Vector menu, select Geoprocessing Tools and then select Buffer. For buffering railways, choose the newly created merged railway shapefile from the Input vector layer dropdown menu. Select the number of segments you want to approximate (the number of side the buffer portions have is 4*the segments you choose; the more, the rounder the buffer result). Set the buffer distance to 200 (from the criteria above). Check the Dissolve buffer results and Add result to canvas boxes and choose where you want the file saved and what you want it called. Click OK and then Close once the process is finished.

Buffer of railway results

Repeat this with each of the remaining shapefiles using the criteria presented above. The finished result should look something like this:

Buffered layers

Merging Shapefiles (again)

Now that all of the original shapefiles have been buffered and clipped to only show the portions that are applicable for hospital site selection, we need to merge all of the shapefiles where we want to be within a certain distance (residential, streets, railways, and fire halls) together to get one easy to analyze and inclusive shapefile. To do this repeat the process outline for merging earlier, but this time choose the files listed above.

Difference

Because we don’t want to include the land that is within a certain distance of public toilets and existing hospitals, we must clip the buffer we made of these files from the original shapefile of all suitable areas that we just created in order to get the final acceptable areas. To do this go to the Vector menu, select Geoprocessing Tools and then select Difference. The Input vector layer should be the merged shapefile you just created from buffers that we wanted to be within a certain distance of. The Difference layer should be the hospital buffer (we will repeat for public washrooms as well). Click Browse and choose where to save the file and what you want to name it and then click OK. Repeat for the washrooms, but this time the Input vector layer should be the file you just of acceptable areas without the hospital buffer and the Difference layer should be the washroom buffer.

Dissolve

Because we performed multiple operations on the final file, we should dissolve everything to make one clean and inclusive shapefile. To do this, go to the Vector menu, select Geoprocessing Tools and then select Dissolve. The Input vector layer should be the shapefile you just creating when dissolving the public washroom buffer from the acceptable areas merge. For the Dissolve field, choose dissolve all. Browse to where you want to save your final shapefile and what you want it to be called and click OK and Close.

Dissolve parameters

The final result of all of the processes we have performed should look something like this:

Final acceptable areas shapefile

Making a Map

Once we have produced the data that we want to showcase, we can use QGIS to make an aesthetically pleasing map. First, turn on all of the layers that you would like to be showcased and turn off all others by selecting and unselecting the checkbox next to each layer name. For example, I have chosen to showcase the location of existing hospitals, roads, railways and the land that is suitable for the placement of the next hospital to be built. Select Project -> New Printer Composer and then type a name for your map in the text box and select OK (it does not have to be the same as the title you place on your final map). In the pop-up window, select Layout -> Add Map and then draw a rectangle on your canvas where you would like your map. To re-position your map display, select Layout -> Move Content. Now you can drag your map into place and zoom in and out. Under the Item Properties tab on the right hand side, you can also change the scale to get the perfect sizing.

Changing the scale of the map

To add a title, select Layout-> Add Label and draw a box for your title. Under Item Properties -> Label you can type your title in the textbox and change the font type, size, colour etc.

To add a north arrow, select Layout -> Add Image and draw a box on your canvas. Under Item Properties -> Search directories you can view different North Arrows and choose which one you would like to use.

Choosing a north arrow

Similarly, you can add a scale bar by selecting Layout -> Add Scalebar.

To add a legend select Layout -> Add Legend. To show only the legend items that are present on your current map, select the icon that resembles a filter cone under the Item Properties -> Legend items menu. To rename legend items, double click a legend item and enter the text you want displayed. You can also rearrange legend items by dragging them up and down.

Once you are happy with your map, you can export it as an image, SVG or PDF by selecting Composer from the top left hand menu and choosing either Export as Image, Export as SVG or Export as PDF.

Final Map

Conclusion

QGIS is a well crafted and easy to use software that in this instance has allowed the production of a map that showcases suitable areas for the future placement of a hospital in Vancouver City, BC. This is just an example of the many ways that a few shapefiles can be manipulated to produce an informative map showcasing site-suitability of a specific building. It also shows that even people with no money for a software license can identify suitable areas for the placement of a multitude of things.

References