3.2.1 Background

Geographic locations are sometimes collected and stored in tables as X,Y coordinates. This section demonstrates how to import X,Y coordinate data on health facilities into QGIS and prepare a map of service coverage.

3.2.2 Objectives

You will need the files for Section_3_2 to complete this module.

You have been asked to provide a summary of health facilities per district that offer HIV services. You have a list of health facilities with their X,Y coordinates in Excel, but no information regarding the district, province, or sector to which they belong.

3.2.3 Add X,Y coordinate data

  1. In your Exercise_Data folder, open the file Health_Facilities.xlsx.
  2. Save it as a CSV file in the MyExercises\Data folder under the same name.
    Step 2
  3. Launch QGIS and open Step 3 Exercise_3b.qgs: .
  4. This opens a map of Rwanda sectors.
    Step 4
  5. Next, add the .csv file you created in step 2 above.
  6. On the QGIS main menu, click on Layer > Add Layer > Add Delimited Text Layer.
    Step 6
  7. In the dialog box that opens, browse to your folder and select the CSV file you created in step 2 above (Health_Facilities.csv) and click Open.
    Step 7
  8. This data has X,Y coordinates, so we will use the geometry definition options.
  9. In the Geometry definition, select Long for the X field and Lat for the Y field; click OK.
    Step 9
  10. The health facilities are added to the map.
    Step 10
  11. This is, however, a temporary file. We will save it as a shapefile.
  12. Right-click on the Health_Facilities layer and select Save As.
  13. Browse to the MyExercises\Data folder and save it there as Health_Facilities.shp.

3.2.4 Change the CRS (coordinate reference system)

  1. The shapefiles we have for Rwanda are in meters in a custom coordinate reference system. The file of X,Y coordinates is in decimal degrees. We have to save our file in the same coordinate system as the rest of the files.
  2. In the dialog box, click on the pull-down menu for CRS.
    Step 15
  3. Select Project CRS, which is the custom CRS for Rwanda.
  4. Ensure that the Add saved file to map option is selected in the next dialog box.
    Step 17
  5. Click OK.
  6. The new shapefile has been added to the map.
  7. Remove the temporary Health_Facilities layer by right-clicking on it and selecting Remove. The temporary layer is directly below the new file.
    Step 20
  8. Right-click on the Health_Facilities layer to open the attribute table. You will notice that it is a list of health facilities, but we have no way of telling which districts they fall in just by looking at the table. In this exercise, our aim is to provide a summary of health facilities per district using GIS tools. To solve this problem, we will perform a spatial join, which is a way of transferring attributes from one layer to another based on their spatial relationship (i.e., where they can be found).

3.2.5 Spatial join

spatial join is a GIS operation that appends data from one feature layer's attribute table to another layer based on the location (spatial relationship). The next steps will demonstrate how to update the health facilities layers with attributes from the sectors layer.

  1. Click on Health_Facilities in your layer list to highlight.
  2. On the main menu, go to Vector > Data Management > Join Attributes by Location.
    Step 23

 

  1. In the dialog box, your Target vector layer should be Health_Facilities (we want to transfer attributes to this layer).
  2. Select Sectors for the Join vector layer (we want to transfer attributes from this layer).
  3. Browse to your exercise data folder and save the file as HF_Join.shp. Click OK.
    Steps 24-26
  4. Click Yes on the next dialog box to add the new layer to the table of contents.
    Step 27
  5. Close the join attributes dialog box.
  6. HF_Join layer is now added to your map.
  7. Open the attribute table and scroll to the right. New fields for district, province, and sector have been added to the table.

3.2.6 Dissolve data

Dissolve is a GIS operation that combines (merges) polygons based on a common attribute. For example, if you have a file at a lower level of administration (like districts), you can dissolve (merge) the districts into their respective provinces. This creates a new layer file of provinces.

  1. Our task was to determine how many facilities are in each district. However, we have been provided with a layer of sectors. We will create a new layer of districts by dissolving (merging) the sectors into their respective districts.
  2. Turn off the HF_Join and Health_Facilities layers.
  3. On the main menu, go to Vector > Geoprocessing Tools > Dissolve.
    Step 33
  4. Ensure your Input vector layer is Sectors.
  5. For the Dissolve field, select district from the pull-down menu.
  6. Browse and save the file in your exercise data folder as Districts_dissolve.shp.
  7. Click OK.
    Steps 34-37
  8. The new layer has been added to your map. Close the dissolve dialog box.
  9. Turn your new layer off, and then on, to see the difference.
  10. Open the attribute table of the new layer and scroll through it. How many districts do we have?

3.2.7 Spatial join with summary statistics

In order to summarize the number of health facilities per district, we must carry out a spatial join with summary statistics. This will sum the number of health facilities and add that to our Districts_dissolve layer.

  1. Turn on the HF_Join layer.
  2. On the main menu, go to Vector > Data Management > Join Attributes by Location.
    Step 42
  3. In the Join attributes by location dialog box, select Districts_dissolve as the Target vector layer.
  4. Select HF_Join as the Join vector layer.
  5. In the Attribute Summary, several options are given for summary statistics. Click on the box next to Mean to deselect it, and click next to Sum to select. We want the tool to sum up the number of facilities per district.
    Steps 43-45
  6. Browse to your exercise data folder and save the file as Districts_HF_Summary.shp.
  7. Click OK. Click Yes at the next dialog box to add the new layer to your map document.
  8. Turn off HF_Join layer.
  9. Open the attribute table of the Districts_HF_Summary layer and scroll to the right. There will be a new column, "Count," which has the total number of facilities counted per district.
  10. Our table has a lot of unnecessary fields, so we will clean it up.
  11. Click the toggle edit mode button on the toolbar, then click on the column delete button (refer to graphic below).
    Step 51
  12. In the Delete Attributes dialog box, select the following columns to delete: SUMID, SUMLat, SUMLong, SUMOBJECTI, SUMShape_L, SUMShape_1, SUMShape_A, and SUMArea_sq.
  13. Click OK when done.
    Steps 52-53
  14. Save your edits and exit edit mode.
    Step 54
  15. Close the attribute table.
  16. Save your project in the MyExercises folder.

Practice exercises

  1. Create a choropleth of HIV service coverage at the district level.
    1. Hint: double-click on Districts HF Summary and select style in the layer properties.
    2. Change to Graduated Symbol and select Count as your column field.
    3. Create a map layout and export your map.
    4. Create a PowerPoint presentation of your findings.
  2. Create a choropleth map of health facility distribution by province.
    1. Hint: Repeat steps 34–60. Dissolve the sectors by province.

Top