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

From CUOSGwiki
Jump to navigationJump to search
 
(80 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
== Purpose ==
 
== 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) by manipulating spatial data. This tutorial will demonstrate how to use QGIS for site suitability analysis of a hospital in Vancouver, BC.
+
The purpose of this tutorial is to show users how to perform a site suitability analysis for hospital placement, using QGIS. This tutorial will focus on Vancouver, BC to provide an example of how to complete this task. In the process users will gain a better understanding of free and open source software (FOSS), learn how to extract spatial data from Google Earth for use in other GIS software, as well as how to set up and manipulate data in QGIS.
   
 
== Introduction ==
 
== 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:
+
When building a new hospital, there are criteria that should be followed in order to find the most appropriate location. These criteria consist of required proximities or distances from certain features, such as roads and public washrooms. Using GIS software, a map can be created of all areas in a city that meet these criteria, which can be used to select a hospital location. In this tutorial, a map of suitable areas for hospital construction in Vancouver will be created. The criteria used in this tutorial will be based on two papers (GIS-Based Multi-Criteria Analysis for Hospital Site Selection in Haidian District of Beijing (Zhou and Wu, 2012) & Hospital Site Selection Using Two-Stage Fuzzy Multi-Criteria Decision Making Process (Soltani and Morandi, 2011)) and are summarized in the following image:
   
  +
[[File:HospitalCriteria.PNG|450px|thumb|none|Criteria for hospital site selection]]
 
  +
[[File:HospitalCriteria.PNG|600px|thumb|none|Criteria for hospital site selection]]
   
 
== Software ==
 
== Software ==
  +
The two software packages required for this tutorial are QGIS and Google Earth. If you do not already have these on your computer, you can use the following instructions to get them.
The two software packages required for this tutorial are QGIS and Google Earth. To download QGIS, click on this [https://www.qgis.org/en/site/forusers/download.html 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. To download Google Earth, click this [https://www.google.com/earth/download/gep/agree.html 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, you are ready to download the required data for this tutorial.
 
   
  +
[[File:Main_DL.jpg]]
== Data ==
 
  +
To download QGIS, click on this [https://www.qgis.org/en/site/forusers/download.html link] and choose which version you would like. Version 3.8 under the "Latest Release" section will be used for this tutorial. Other version will be able to do everything in this tutorial, though the names and locations of certain tools and options may be different. The alternative is the "Long term release repository" version, which is an older release so it's more stable, but also has less features.
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.
 
   
  +
[[File:Choices.jpg]]
[[File:FileList.png|450px|thumb|none|For example, we want to download the Fire halls file, so we click on the Fire halls hyperlink]]
 
   
  +
[[File:Latest_Release3.jpg]]
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.
 
   
[[File:FireHallSHP.PNG|450px|thumb|none|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.
 
   
  +
[[File:Google_Earth4.jpg]]
[[File:Extract.png|450px|thumb|none|Right click the zipped folder and select Extract All]]
 
   
  +
To download Google Earth, click this [https://www.google.com/earth/download/gep/agree.html link] and select '''Agree and Download'''. Once you have downloaded and installed both software packages, you are ready to download the required data for this tutorial.
Here is what the folder looks like once all of the data has been downloaded and extracted:
 
   
  +
== Data ==
[[File:FilesinFolder.PNG|450px|thumb|none|Folder with all downloaded files]]
 
  +
Create a working folder wherever you would like your project file to be saved, and within it make another folder titled "Data". This is where all of the data needed to complete this tutorial will be stored. For this project, all the required data is available at http://data.vancouver.ca/datacatalogue/, except for the file for hospital locations which will be extracted from Google Earth. From the Vancouver data catalogue, you will need to download the following files:
  +
-[ftp://webftp.vancouver.ca/OpenData/shape/fire_halls_shp.zip Fire halls]
  +
-[ftp://webftp.vancouver.ca/OpenData/shape/local_area_boundary_shp.zip Local area boundary]
  +
-[ftp://webftp.vancouver.ca/opendata/shape/railways_shp.zip Railway]
  +
-[ftp://webftp.vancouver.ca/OpenData/shape/rapid_transit_line_shp.zip Rapid transit lines]
  +
-[ftp://webftp.vancouver.ca/OpenData/shape/shape_city_streets.zip City streets package]
  +
-[ftp://webftp.vancouver.ca/OpenData/shape/zoning_districts_shp.zip Zoning districts and labels]
  +
-[http://data.vancouver.ca/download/kml/public_washrooms.kmz Public washrooms]
   
  +
To download the files, simply click the links above. The files are all in SHP format, except for Public washrooms which does not have an SHP version available, so it is a KML file. Next extract the contents of the files you downloaded into the "Data" folder you created earlier.
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, search for hospitals in Vancouver, BC.
 
  +
  +
[[File:Extract_All.jpg]]
  +
  +
Once you have downloaded the files, you will need to extract the zipped files in your DATA folder.
  +
  +
Now only one more file is needed, which will contain the location of all of the existing hospitals in Vancouver. Because there is not file for this in the Vancouver Data Catalogue, we will use Google Earth to find all hospital locations in Vancouver, then export them as a KMZ file. To do this, open Google Earth and search for "hospitals in Vancouver, BC".
   
 
[[File:Hospitals.PNG|450px|thumb|none|Results for the search hospitals in Vancouver, BC]]
 
[[File:Hospitals.PNG|450px|thumb|none|Results for the search hospitals in Vancouver, BC]]
  +
  +
[[File:Copy_Results5.jpg]]
   
 
Next, click the folder icon below the search results that says “Copy the current search results to My Places” when you hover over it.
 
Next, click the folder icon below the search results that says “Copy the current search results to My Places” when you hover over it.
Line 35: Line 50:
 
[[File:Copytomyplaces.png|450px|thumb|none|Click the highlighted folder icon to move the search results into your My Places folder]]
 
[[File:Copytomyplaces.png|450px|thumb|none|Click the highlighted folder icon to move the search results into your My Places folder]]
   
  +
[[File:MyPlaces6.jpg]]
Now right click on the folder containing your search results and select Save Place As...
 
  +
  +
Now right click on the folder containing your search results and select '''Save Place As... '''
   
 
[[File:Saveplaceas.png|450px|thumb|none|Right click the folder and select Save Place As]]
 
[[File:Saveplaceas.png|450px|thumb|none|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.
+
Give the file a name and make sure the ''Save as type:'' is Kmz, then save it into your "Data" folder. Now that you have all the required files, you are ready to start the tutorial.
   
  +
== Tutorial ==
[[File:SavingAfile.PNG|450px|thumb|none|Save your newly created file]]
 
   
  +
[[File:NewProject.jpg]]
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.
 
   
  +
Now that you have downloaded the software and collected the required data, it is time to begin. Open QGIS, click the '''New Project''' button (white piece of paper) in the top left to start a new project. Save the project file into your working folder under whatever name you choose (try not to use spaces or funny characters in your file name).
== 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 ===
 
=== 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.
+
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 '''Properties'''. The Project Properties windows will open. Go to the '''CRS''' tab, then in the search box search for "NAD83(CSRS) / UTM zone 10N" and select it from the list. This will automatically project all files in your data frame according to this coordinate reference system. Click '''Apply''' to apply the change. From this window, under the '''General''' tab, you can set the project's home directory, which should be your "Data" folder. Once this is done, click '''Apply''' then '''OK'''.
  +
   
[[File:UTMzone.PNG|450px|thumb|none|Setting Projection to NAD83(CSRS) / UTM zone 10N]]
+
[[File:Projection.jpg]]
   
 
=== Importing Data ===
 
=== Importing Data ===
  +
To import the required data into QGIS, you will use the Browser panel on the left of the screen. Expand the "Project Home" section and you will see all the files you downloaded. Click the files you wish to import to select them (you can select multiple by holding the "Ctrl" key), then drag them into the center of the screen. All your files will now be added to the data frame. If you do not see anything, right click on one of the layers in the "Layers" panel, and select '''Zoom to Layer'''. You should have all the same layers as those seen in the screenshot below.
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 clipped.
 
[[File:ColouredLayers.PNG|450px|thumb|none|Display of all of the imported layers]]
 
   
  +
[[File:BeforeReorder.jpg|caption]] Before reordering
=== Editing Attribute Tables: Selecting by Expression ===
 
Right click on the accidents layer and select '''Open Attribute Table'''. An attribute table of the accident layer will appear and it will have the different types of impact and the two street names where the accident occurred. Once you have the attribute table open, select '''Select Features Using an Expression'''. A '''Select By Expression''' window will appear, and in the function list, expand the '''Fields and Values''' and select '''Impact Type'''. 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 impact types that were seen in the attribute table.
 
   
  +
[[File:Reorder.jpg|caption]] After reordering
In the expression box of the select by expression window. When you double click on the '''Impact Type''', "ImpactType" will appear. Once that appears, you select the equal (=) sign where the available operators are listed. The next step is to select a field value. In this example, the first field value selected is '''Angle'''. The expression should be "ImpactType" = 'Angle'. Once this expression has been selected, the impact types that are '''angle''' are now highlighted on your map.
 
   
  +
Now, reorder the layers by dragging them in the "Layers" panel so that as many as possible are visible. You can also change the color and symbols for the layers by clicking them and changing the setting in the "Layer Styling" panel on the right (if this is not visible for you, right click the top toolbar and click '''Layer Styling Panel''').You’ll notice that some of the points in the hospital file you created don’t lie within Vancouver's boundaries; this is not a problem as later on in this tutorial the non-valid points will be dissolved. Once you have all the required data imported and looking acceptable, you can move on to the next step.
[[File:SelectionExpression.PNG|400px|thumb|none|Selection Expression]]
 
   
  +
[[File:Capture2.PNG|500px|thumb|none|upright=2.0|Display of all of the imported layers]]
=== Saving Selected Points (Shapefile) ===
 
The selected points that are now highlight can be saved as their own shapefile. To do this, right click on the accidents 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'''.
 
   
  +
=== Converting KMZ to Shapefile ===
[[File:ImpactTypeAngle.PNG|200px|thumb|none|Angle impact accident type point shapefile after it has been added to map]]
 
  +
In order to be able to perform operations such as buffer and clip on the public washroom and hospital files, they will need to be converted from KMZ format to SHP. To do this, right click the file from the "Layers" panel, then select '''Export > Save Features As'''. In the pop-up window, make sure the Format is ''ESRI Shapefile'', then choose the output name and location (your "Data" folder) by selecting the '''Browse''' button. Make sure the CRS is ''Project CRS (EPSG:26910 -NAD83 / UTM zone 10 N)'' then click '''OK'''. Do this for the public washroom file and the hospital file. Once both shapefiles have been added, you can remove their original layers from the project.
   
  +
[[File:SaveAsShapefile.PNG|300px|thumb|none|Converting KMZ to shapefile]]
Repeat both the '''Editing Attribute Tables: Selecting by Expression''' and '''Saving Selected Points (Shapefile)''' steps until all the impact types have been saved as their own individual shapefiles.
 
   
  +
=== Extracting Residential Areas from the Zoning Districts ===
[[File:AccidentTypes.PNG|400px|thumb|none|Map of Ottawa with all the different impact types as their own individual shapefiles (Wards shown in different colour scheme to better highlight different accident types)]]
 
   
  +
[[File:Select_Features.jpg]]
=== Selecting a Specific Area ===
 
To select a specific area, open the attribute table for the wards-2010-2 shapefile layer. Click on the '''Select features using an expression''' button.
 
   
  +
One of our criteria for hospital site selection is that the location must be within a certain distance of residential areas, so we need to extract all the residential areas from the zoning districts shapefile. To do this, right-click on the zoning_districts layer and select '''Open Attribute Table'''. The attribute table for the zoning districts will open, and the zoning category for each feature will be shown in the "CATEGORY" column. We want to select all features with categories that contain the word "Dwelling", as this denotes that it is residential. To do this, select '''Select Features Using an Expression''' from the top toolbar. A '''Select By Expression''' window will appear, and for the expression type:
The '''Select By Expression''' window will appear, and in the function list, expand the '''Fields and Values''' and select the specific area you want to study. In this case, it is Barrhaven. Because the wards in this file is listed by number and not name, we must consult a reference list.
 
  +
"CATEGORY" LIKE '%Dwelling%'
   
  +
Now click the '''Select features''' button in the bottom right hand corner and all the desired features will be selected, then click '''Close'''.
[[File:WARDS.PNG|380px|thumb|none|Different Wards in Ottawa and their respective wards numbers]]
 
   
  +
[[File:Expression.PNG|500px|thumb|none|upright=2.0|Selection Expression]]
The expression should be "WARD_NUM" = '3' because we want to select Barrhaven. If we were wanting to select more than one ward at a time, our expression would be for example "WARD_NUM" = '3' OR "WARD_NUM" = '22' which would select both Barrhaven and Gloucester-South Nepean. To save the selected shapefile, right click on the wards-2010-2 layer and select '''Save Selection As''' and a window will appear. In this window, the format that the shapefile should be saved under is "ESRI Shapefile", give the shapefile a name and toggle on '''Add saved file to map'''.
 
   
  +
The selected zones that are now highlighted and can be saved as their own shapefile. To do this, right click on the zoning_districts layer and select '''Export > Save Selected Features As'''. Save it into your "Data" folder with ''ESRI Shapefile'' as the format. Make sure ''Save only selected features'' and ''Add saved file to map'' are toggled on, leave the CRS as is, then click '''OK'''.
[[File:Barrhaven.PNG|400px|thumb|none|Highlighted Barrhaven]]
 
   
  +
[[File:SavingASelection.JPG|500px|thumb|none|upright=2.0|Residential zones shapefile after it has been added to map]]
=== Clipping Files ===
 
When the newly merged shapefile has been made, you can simply clip all of the other information (accidents, roads, railways, pedestrian paths) onto the study area as well. To do this, go to the '''Vector Menu''', select '''Geoprocessing Tools''' and then select '''Clip'''. A clip window will appear and the input vector layer will be what shapefile you want to clip onto the output vector layer. For example, to clip the roads, the input vector layer should be '''Road Segments''' and the clip layer should be the '''Barrhaven shapefile''' we made from our previous selection. For output shapefile, you can browse to the folder that contains all of your other shapefiles and choose a name for your clipped file.
 
   
  +
=== Merging Shapefiles ===
[[File:Clipping.PNG|300px|thumb|none|Clipping window]]
 
   
  +
[[File:Merge_Streets.jpg|caption]] Merging street files
When clipping the other shapefiles, the clip layer remains the same, but the input vector layer changes.
 
Format the style of your clipped shapefiles to your liking.
 
   
  +
[[File:Merge_rail.jpg|caption]] Merging rail files
[[File:BarrhavenClipped.PNG|300px|thumb|none|The output of all layers being clipped to the AOI]]
 
  +
  +
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, click '''Vector > Data Management Tools > Merge Vector Layers'''. For ''Input files'' select all of the files to be merged. Under the ''Merged'' field select ''Save to file'' and save it into your "Data" folder. Uncheck the box for '''Open output file after running algorithm''' then click '''Run in Background'''. Once the operation is completed use the "Browser" panel to add your new file to the data frame (if you don't see it hit the refresh button at the top). Follow these steps to merge all the road shapefiles (lanes, non_city_streets, one_way_streets and public_streets), then all the railway shapefiles (railways and rapid_transit).
   
  +
[[File:MergedFIles.PNG|500px|thumb|none|upright=2.0|The merged street types and railways types]]
=== Analyzing the Data ===
 
   
  +
=== Buffering Files ===
To see how many of each accident type occur, we can look at the attribute table. For example, in our recorded data for Single Vehicle Unattended Accidents in the Barrhaven ward, 10 incidents occurred.
 
  +
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 '''Vector > Geoprocessing Tools > Buffer'''. Start by buffering your newly merged street shapefile. Select that file as the input, the set the distance to 100 meters, as that is the value given in the site suitability criteria. The "Segments" field controls how many line segments make up each quarter-circle in the buffer results, a higher value will give a rounder result, but it will be more complex as well. 25 is a good number of segments, so use that value for this buffer. Check the box saying "Dissolve result", deselect the option to add the output after running, then choose to save the file into your "Data" folder. Leave the rest of the settings untouched and hit '''Run in Background'''. Once it is finished running, close the window then add your new file to the data frame through the "Browser" panel.
   
  +
[[File:Capture3.PNG|400px|thumb|none|Buffer of railway results]]
[[File:SingleVehAcc.PNG|300px|thumb|none|Circle highlights the total number of features within the selected layer for which the attribute table was opened]]
 
   
  +
Repeat this with each of the remaining shapefiles, setting the distance based on the criteria shown in the picture below.
To see how many accidents occur within 100 m of a railway track, we can first create a buffer around our clipped railways shapefile. Select '''Vector''' -> '''Geoprocessing Tools''' -> '''Buffer'''. In this example, a buffer distance of 100m was used and the segments to approximate value was 25 (this mean that our finished polygon will have 100 sides (the higher the segments to approximate value, the smoother the buffer). We save this in our desired folder with a file name of our choice.
 
   
[[File:BufferMelinda.PNG|300px|thumb|none|Buffer window with explained values]]
+
[[File:HospitalCriteria.PNG|600px|thumb|none|Criteria for hospital site selection]]
   
  +
Once you have buffered all the required filed, the finished result should look something like this:
Because we want to know how many accidents of any type occurred within 100 m of a railway, we can clip our original accidents shapefile to our Barrhaven polygon.
 
   
[[File:AccidentsBarrhaven.PNG|300px|thumb|none|Clipping our original accident shapefile to our AOI]]
+
[[File:AllBuffers.PNG|400px|thumb|none|Buffered layers]]
   
  +
=== Merging Shapefiles (again) ===
Here’s the outcome:
 
   
  +
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 with criteria to be within a certain distance (residential, streets, railways, and fire halls). To do this repeat the process outlined for merging earlier, but this time choose the files mentioned here.
[[File:BufferandClip.PNG|300px|thumb|none|Outcome of buffer and clip]]
 
   
  +
=== Difference ===
To find out how many accidents occurred within our buffered region, we can make a clip of accidents in Barrhaven from our railway buffer.
 
  +
Because we want to exclude the land that is within a certain distance of public toilets and existing hospitals, we must remove these areas from the shapefile we created in the previous step. To do this go to '''Vector > Geoprocessing Tools > Difference'''. The ''Input layer'' should be the merged shapefile from the previous step. The ''Difference layer'' should be the hospital buffer (we will repeat it after for public washrooms). Choose to save the file into your "Data" folder, and deselect the option to open the output file after running. Click '''Run in Background''' then once its finished close the window and add the new file to the data frame.
   
[[File:RailwayAccidents.PNG|300px|thumb|none|Clipping accidents that occur within railway buffer]]
+
[[File:Capture4.PNG|500px|thumb|none|Difference tool]]
   
  +
Repeat for the washrooms, but this time the ''Input layer'' should be the difference file you just created, and the ''Difference layer'' should be the washroom buffer.
From the output layer and it’s attribute table we can see that only one accident occurred within 100 m of a railway in Barrhaven.
 
   
  +
=== Dissolve ===
[[File:Accidentsrailway.PNG|300px|thumb|none|Accident that occurred within buffered region]]
 
  +
Because we performed multiple operations on the final file, it will contain many overlapping polygons. To eliminate any overlap we should dissolve everything, making it into one clean and inclusive shapefile. To do this, go to the '''Vector > Geoprocessing Tools > Dissolve'''. The ''Input vector layer'' should be the shapefile you just creating when removing the public washroom buffer from the acceptable areas merge. Have the file be saved into your "Data" folder and deselect the option to open the file after running. Click '''Run in Background''' then once it finishes close the window and add your new file to the data frame.
   
  +
[[File:Capture5.PNG|400px|thumb|none|Dissolve parameters]]
Using these methods, you can perform a multitude of operations to interpret things such as how many accidents occur within a distance from pedestrian pathways, how many accidents occur within a ward, how many accidents occur within a distance from railways, how many of a certain accident type occur within a distance from other accident types etc.
 
   
  +
The final result of all of the processes we have performed should look something like the picture below. This polygon represents all areas of Vancouver that are suitable for hospital construction, according to our criteria.
=== Making a Map ===
 
   
  +
[[File:FinalArea.PNG|400px|thumb|none|Final acceptable areas shapefile]]
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. I want to showcase different types of accidents that occur within Barrhaven so I have selected these layers:
 
   
  +
=== Making a Map ===
[[File:SelectedLayers.PNG|300px|thumb|none|Selected layers]]
 
  +
Now that we have produced the data that we want to showcase, we can use QGIS to make it into a map. First, in the "Layers" panel make sure all the layers you want visible in the final map are checked, and that the ones you don't are unchecked. In our map we will display streets, hospitals, railways, and of course the suitable hospital area we created.
   
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 reposition 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.
+
To make your map layout, go to '''Project > New Print Layout''' then type in a name for your map and select '''OK''' (it does not have to be the same as the title you place on your final map). A new window will then open which lets you design your layout. To add the map to your layout, select '''Add Item > Add Map''' at the top of the screen, then drag out a rectangle on the canvas where you would like it to be. To re-position your map display, use the '''Move item content''' tool which can be activated on the left of the window. To move the map or any other features around the page, use the '''Select/Move item''' tool. You can resize the map by changing the scale, which is under the '''Item Properties''' tab on the right hand side.
   
 
[[File:Scale.PNG|300px|thumb|none|Changing the scale of the map]]
 
[[File:Scale.PNG|300px|thumb|none|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.
+
Once you are happy with the placement and size of your map, you can add the other required components which include a title, legend, scale bar and north-arrow. To add a title, select '''Add Item > Add Label''' and draw a box for your title. In the "Item Properties" panel, under '''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.
+
To add a north arrow, select '''Add Item > Add Picture''' and draw a box on your canvas. In the "Item Properties" panel, under '''Search directories''' you can view different North Arrows and choose which one you would like to use.
   
 
[[File:Northarrow.PNG|300px|thumb|none|Choosing a north arrow]]
 
[[File:Northarrow.PNG|300px|thumb|none|Choosing a north arrow]]
   
Similarly, you can add a scale bar by selecting '''Layout''' -> '''Add Scalebar'''.
+
Similarly, you can add a scale bar by selecting '''Add Item > 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.
+
To add a legend select '''Add Item > 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'''.
 
   
  +
Once you have found a good placement for all the items, and have tuned their properties to your liking, you can export the layout as an image, SVG or PDF by selecting '''Layout''' in the top left and choosing either '''Export as Image''', '''Export as SVG''' or '''Export as PDF'''.
[[File:Map2.png|300px|thumb|none|Final Map]]
 
  +
  +
[[File:FinalMap2.JPG|600px|thumb|center|upright=2.0|Final Map]]
   
 
== Conclusion ==
 
== Conclusion ==
  +
In this tutorial, you have learned how to produce a map in QGIS, showing suitable areas for hospital placement in Vancouver, BC, based on a specified set of criteria. However, the applicability of the techniques learned here is not limited just to this location, these criteria, or this exact purpose. By using different data and altering the buffer distances, these steps could be used to determine suitable placement areas for almost anything, and according to any set of criteria. More broadly, the skills acquired here, relating to setting up a QGIS project, manipulating data, and creating a map layout, can be used for countless other purposes. QGIS is a well-crafted and easy to use software, and this tutorial is just an example of the many ways that data can be manipulated within it to perform geographic analysis and produce informative maps. It also shows that the barrier to entry for GIS analysis is much lower than many people realize, as QGIS is free as long as you have a computer to run it.
QGIS is an intuitive and user-friendly software that in this instance has allowed the production of a map that showcases traffic accidents in the Barrhaven ward of Ottawa as well as allowed the user to analyze different scenarios. This is just an example of the many ways that a few shapefiles can be combined to produce a multitude of useful and easily understood data
 
   
 
== References ==
 
== References ==
  +
*City of Vancouver (2017). Open Data catalogue | City of Vancouver. Retrieved December 18, 2017 from City of Vancouver http://data.vancouver.ca/datacatalogue/index.htm
 
*City of Ottawa. (2017). OpenData Ottawa | City of Ottawa. Retrieved October 9, 2017, From City of Ottawa: http://data.ottawa.ca/
+
*Google (2017). Download Google Earth. Retrieved December 18, 2017 from Google https://www.google.com/earth/download/gep/agree.html
  +
*QGIS. (2014). Download QGIS. Retrieved December 18, 2017 from QGIS http://www.qgis.org/en/site/forusers/download.html
 
  +
*Soltani, A. & Marandi, E. Z. (2011). Hospital Site Selection Using Two-Stage Fuzzy Multi-Criteria Decision Making Process. Journal of Urban and Environmental Engineering, 5 (1). Retrieved from https://doaj.org/article/62479c17294e4cfb9a5777caaf2c7a38
*City of Ottawa. (2014). Safer Roads Ottawa Program | City of Ottawa. Retrieved December 20, 2014, from City of Ottawa: http://ottawa.ca/en/residents/transportation-and-parking/safer-roads-ottawa-program
 
  +
*Zhou, L. & Wu, J. (2012). GIS-Based Multi-Criteria Analysis for Hospital Site Selection in Haidian District of Beijing. Retrieved October 24, 2017 from https://www.diva-portal.org/smash/get/diva2:555935/FULLTEXT01.pdf
 
*City of Ottawa. (2014). Safety Improvement Program | City of Ottawa. Retrieved December 20, 2014, from City of Ottawa: http://ottawa.ca/en/residents/transportation-and-parking/road-safety/safety-improvement-program
 
 
*MacOdrum Library. (2014). Maps, Data and Government Information Centre | MacOdrum Library. Retrieved December 19, 2014, from MacOdrum Library: https://www.library.carleton.ca/contact/service-points/maps-data-and-government-information-centre
 
 
*QGIS. (2014). Discover QGIS. Retrieved December 20, 2014, from QGIS: http://www.qgis.org/en/site/about/index.html
 
 
*QGIS. (2014). Download QGIS. Retrieved December 20, 2014, from QGIS: http://www.qgis.org/en/site/forusers/download.html
 
 
*Wikipedia. (2017). Wards of the City of Ottawa. Retrieved October 13, 2017, from https://en.wikipedia.org/wiki/Wards_of_the_City_of_Ottawa
 

Latest revision as of 21:40, 3 October 2019

Purpose

The purpose of this tutorial is to show users how to perform a site suitability analysis for hospital placement, using QGIS. This tutorial will focus on Vancouver, BC to provide an example of how to complete this task. In the process users will gain a better understanding of free and open source software (FOSS), learn how to extract spatial data from Google Earth for use in other GIS software, as well as how to set up and manipulate data in QGIS.

Introduction

When building a new hospital, there are criteria that should be followed in order to find the most appropriate location. These criteria consist of required proximities or distances from certain features, such as roads and public washrooms. Using GIS software, a map can be created of all areas in a city that meet these criteria, which can be used to select a hospital location. In this tutorial, a map of suitable areas for hospital construction in Vancouver will be created. The criteria used in this tutorial will be based on two papers (GIS-Based Multi-Criteria Analysis for Hospital Site Selection in Haidian District of Beijing (Zhou and Wu, 2012) & Hospital Site Selection Using Two-Stage Fuzzy Multi-Criteria Decision Making Process (Soltani and Morandi, 2011)) and are summarized in the following image:


Criteria for hospital site selection

Software

The two software packages required for this tutorial are QGIS and Google Earth. If you do not already have these on your computer, you can use the following instructions to get them.

Main DL.jpg To download QGIS, click on this link and choose which version you would like. Version 3.8 under the "Latest Release" section will be used for this tutorial. Other version will be able to do everything in this tutorial, though the names and locations of certain tools and options may be different. The alternative is the "Long term release repository" version, which is an older release so it's more stable, but also has less features.

Choices.jpg

Latest Release3.jpg


Google Earth4.jpg

To download Google Earth, click this link and select Agree and Download. 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 project file to be saved, and within it make another folder titled "Data". This is where all of the data needed to complete this tutorial will be stored. For this project, all the required data is available at http://data.vancouver.ca/datacatalogue/, except for the file for hospital locations which will be extracted from Google Earth. From the Vancouver data catalogue, you will need to download the following files:

-Fire halls
-Local area boundary
-Railway
-Rapid transit lines
-City streets package
-Zoning districts and labels
-Public washrooms

To download the files, simply click the links above. The files are all in SHP format, except for Public washrooms which does not have an SHP version available, so it is a KML file. Next extract the contents of the files you downloaded into the "Data" folder you created earlier.

Extract All.jpg

Once you have downloaded the files, you will need to extract the zipped files in your DATA folder.

Now only one more file is needed, which will contain the location of all of the existing hospitals in Vancouver. Because there is not file for this in the Vancouver Data Catalogue, we will use Google Earth to find all hospital locations in Vancouver, then export them as a KMZ file. To do this, open Google Earth and search for "hospitals in Vancouver, BC".

Results for the search hospitals in Vancouver, BC

Copy Results5.jpg

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

MyPlaces6.jpg

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

Right click the folder and select Save Place As

Give the file a name and make sure the Save as type: is Kmz, then save it into your "Data" folder. Now that you have all the required files, you are ready to start the tutorial.

Tutorial

NewProject.jpg

Now that you have downloaded the software and collected the required data, it is time to begin. Open QGIS, click the New Project button (white piece of paper) in the top left to start a new project. Save the project file into 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 Properties. The Project Properties windows will open. Go to the CRS tab, then in the search box search for "NAD83(CSRS) / UTM zone 10N" and select it from the list. This will automatically project all files in your data frame according to this coordinate reference system. Click Apply to apply the change. From this window, under the General tab, you can set the project's home directory, which should be your "Data" folder. Once this is done, click Apply then OK.


Projection.jpg

Importing Data

To import the required data into QGIS, you will use the Browser panel on the left of the screen. Expand the "Project Home" section and you will see all the files you downloaded. Click the files you wish to import to select them (you can select multiple by holding the "Ctrl" key), then drag them into the center of the screen. All your files will now be added to the data frame. If you do not see anything, right click on one of the layers in the "Layers" panel, and select Zoom to Layer. You should have all the same layers as those seen in the screenshot below.

caption Before reordering

caption After reordering

Now, reorder the layers by dragging them in the "Layers" panel so that as many as possible are visible. You can also change the color and symbols for the layers by clicking them and changing the setting in the "Layer Styling" panel on the right (if this is not visible for you, right click the top toolbar and click Layer Styling Panel).You’ll notice that some of the points in the hospital file you created don’t lie within Vancouver's boundaries; this is not a problem as later on in this tutorial the non-valid points will be dissolved. Once you have all the required data imported and looking acceptable, you can move on to the next step.

Display of all of the imported layers

Converting KMZ to Shapefile

In order to be able to perform operations such as buffer and clip on the public washroom and hospital files, they will need to be converted from KMZ format to SHP. To do this, right click the file from the "Layers" panel, then select Export > Save Features As. In the pop-up window, make sure the Format is ESRI Shapefile, then choose the output name and location (your "Data" folder) by selecting the Browse button. Make sure the CRS is Project CRS (EPSG:26910 -NAD83 / UTM zone 10 N) then click OK. Do this for the public washroom file and the hospital file. Once both shapefiles have been added, you can remove their original layers from the project.

Converting KMZ to shapefile

Extracting Residential Areas from the Zoning Districts

Select Features.jpg

One of our criteria for hospital site selection is that the location must be within a certain distance of residential areas, so we need to extract all the residential areas from the zoning districts shapefile. To do this, right-click on the zoning_districts layer and select Open Attribute Table. The attribute table for the zoning districts will open, and the zoning category for each feature will be shown in the "CATEGORY" column. We want to select all features with categories that contain the word "Dwelling", as this denotes that it is residential. To do this, select Select Features Using an Expression from the top toolbar. A Select By Expression window will appear, and for the expression type:

"CATEGORY" LIKE '%Dwelling%'

Now click the Select features button in the bottom right hand corner and all the desired features will be selected, then click Close.

Selection Expression

The selected zones that are now highlighted and can be saved as their own shapefile. To do this, right click on the zoning_districts layer and select Export > Save Selected Features As. Save it into your "Data" folder with ESRI Shapefile as the format. Make sure Save only selected features and Add saved file to map are toggled on, leave the CRS as is, then click OK.

Residential zones shapefile after it has been added to map

Merging Shapefiles

caption Merging street files

caption Merging rail files

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, click Vector > Data Management Tools > Merge Vector Layers. For Input files select all of the files to be merged. Under the Merged field select Save to file and save it into your "Data" folder. Uncheck the box for Open output file after running algorithm then click Run in Background. Once the operation is completed use the "Browser" panel to add your new file to the data frame (if you don't see it hit the refresh button at the top). Follow these steps to merge all the road shapefiles (lanes, non_city_streets, one_way_streets and public_streets), then all the railway shapefiles (railways and rapid_transit).

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 Vector > Geoprocessing Tools > Buffer. Start by buffering your newly merged street shapefile. Select that file as the input, the set the distance to 100 meters, as that is the value given in the site suitability criteria. The "Segments" field controls how many line segments make up each quarter-circle in the buffer results, a higher value will give a rounder result, but it will be more complex as well. 25 is a good number of segments, so use that value for this buffer. Check the box saying "Dissolve result", deselect the option to add the output after running, then choose to save the file into your "Data" folder. Leave the rest of the settings untouched and hit Run in Background. Once it is finished running, close the window then add your new file to the data frame through the "Browser" panel.

Buffer of railway results

Repeat this with each of the remaining shapefiles, setting the distance based on the criteria shown in the picture below.

Criteria for hospital site selection

Once you have buffered all the required filed, 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 with criteria to be within a certain distance (residential, streets, railways, and fire halls). To do this repeat the process outlined for merging earlier, but this time choose the files mentioned here.

Difference

Because we want to exclude the land that is within a certain distance of public toilets and existing hospitals, we must remove these areas from the shapefile we created in the previous step. To do this go to Vector > Geoprocessing Tools > Difference. The Input layer should be the merged shapefile from the previous step. The Difference layer should be the hospital buffer (we will repeat it after for public washrooms). Choose to save the file into your "Data" folder, and deselect the option to open the output file after running. Click Run in Background then once its finished close the window and add the new file to the data frame.

Difference tool

Repeat for the washrooms, but this time the Input layer should be the difference file you just created, and the Difference layer should be the washroom buffer.

Dissolve

Because we performed multiple operations on the final file, it will contain many overlapping polygons. To eliminate any overlap we should dissolve everything, making it into one clean and inclusive shapefile. To do this, go to the Vector > Geoprocessing Tools > Dissolve. The Input vector layer should be the shapefile you just creating when removing the public washroom buffer from the acceptable areas merge. Have the file be saved into your "Data" folder and deselect the option to open the file after running. Click Run in Background then once it finishes close the window and add your new file to the data frame.

Dissolve parameters

The final result of all of the processes we have performed should look something like the picture below. This polygon represents all areas of Vancouver that are suitable for hospital construction, according to our criteria.

Final acceptable areas shapefile

Making a Map

Now that we have produced the data that we want to showcase, we can use QGIS to make it into a map. First, in the "Layers" panel make sure all the layers you want visible in the final map are checked, and that the ones you don't are unchecked. In our map we will display streets, hospitals, railways, and of course the suitable hospital area we created.

To make your map layout, go to Project > New Print Layout then type in a name for your map and select OK (it does not have to be the same as the title you place on your final map). A new window will then open which lets you design your layout. To add the map to your layout, select Add Item > Add Map at the top of the screen, then drag out a rectangle on the canvas where you would like it to be. To re-position your map display, use the Move item content tool which can be activated on the left of the window. To move the map or any other features around the page, use the Select/Move item tool. You can resize the map by changing the scale, which is under the Item Properties tab on the right hand side.

Changing the scale of the map

Once you are happy with the placement and size of your map, you can add the other required components which include a title, legend, scale bar and north-arrow. To add a title, select Add Item > Add Label and draw a box for your title. In the "Item Properties" panel, under Label you can type your title in the textbox and change the font type, size, colour etc.

To add a north arrow, select Add Item > Add Picture and draw a box on your canvas. In the "Item Properties" panel, under 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 Add Item > Add Scalebar.

To add a legend select Add Item > 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 have found a good placement for all the items, and have tuned their properties to your liking, you can export the layout as an image, SVG or PDF by selecting Layout in the top left and choosing either Export as Image, Export as SVG or Export as PDF.

Final Map

Conclusion

In this tutorial, you have learned how to produce a map in QGIS, showing suitable areas for hospital placement in Vancouver, BC, based on a specified set of criteria. However, the applicability of the techniques learned here is not limited just to this location, these criteria, or this exact purpose. By using different data and altering the buffer distances, these steps could be used to determine suitable placement areas for almost anything, and according to any set of criteria. More broadly, the skills acquired here, relating to setting up a QGIS project, manipulating data, and creating a map layout, can be used for countless other purposes. QGIS is a well-crafted and easy to use software, and this tutorial is just an example of the many ways that data can be manipulated within it to perform geographic analysis and produce informative maps. It also shows that the barrier to entry for GIS analysis is much lower than many people realize, as QGIS is free as long as you have a computer to run it.

References