14
Spatial Analysis I Lex Comber, April 2011 1 Practical 2: Spatial Analysis I The aim of this exercise is for you to develop the skills needed to develop spatial analyses. By the end of this practical you should be able to: Import, interrogate and analyse text data with a spatial reference (e.g. as a result of GPS-linked survey) Visualise spatial data Perform fundamental spatial analyses on vector data such point in polygon operations Understand and manipulate the outputs of overlay operations Produce and export maps You should copy all of the folder Prac2 to your file space and work from that, setting write permissions on the folder and files as you need. In this exercise you will use two datasets: anonymised EMS data from 2007 in Niigata of incidents attended by an Ambulance and 2005 census data. The actual data has been geographical adjusted to protect patient confidentiality. The aim of this study is to explore the spatial relationship between serious and critical EMS cases and age using simple demographic profiling of areas in which the EMS cases originated. 1. Start ArcMap Launch ArcMap by selecting Start > ArcGIS > ArcMap Add the following shapefile data, niigata_2005_01.shp and open EMS_cases_anon.csv The shapefile is in a standard GIS format and has at least 3 component files, but sometimes has as many as 8 associated files. Have a look at the different files in windows explorer. The text file is a simple Comma Separated Variable (csv) file, with field headers and two sets of X and Y attributes (metres and degrees) such as are returned by a GPS. This is a very common form of ‘raw’ data, that needs to be imported into ArcMap and to have its geography made explicit. You will notice that when a text file is loaded into ArcMap, it defaults to the ‘Source’ view showing file paths, rather than the Display view (see the tabs at the bottom of the table of contents). Open the EMS data (right click > Open) and check that the data is complete and has loaded. Then, right click on the file and select Display XY data. In the next window, make sure that you specify Xm and Ym correctly. Accept the message – this will give the data records an ID. Hint: Common problems in loading csv / text data that you might wish to remember when you import your data to a GIS in future are: - it is open in another software – e.g. Excel - the field names have characters that are not allowed (simple text and numbers, no spaces or non-standard characters) - the data has gaps – make sure that each cell has a data entry. You may wish to use ‘-9999’ for nodata entries - the data is inconsistent with different data types in the same field (e.g. text in one cell, numbers in another). ArcMap is

Practical 2: Spatial Analysis I - University of Tokyo 2 Spatial... · Practical 2: Spatial Analysis I . ... - it is open in another software – e.g. Excel - the field names have

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Practical 2: Spatial Analysis I - University of Tokyo 2 Spatial... · Practical 2: Spatial Analysis I . ... - it is open in another software – e.g. Excel - the field names have

Spatial Analysis I Lex Comber, April 2011

1

Practical 2: Spatial Analysis I The aim of this exercise is for you to develop the skills needed to develop spatial analyses. By the end of this practical you should be able to:

• Import, interrogate and analyse text data with a spatial reference (e.g. as a result of GPS-linked survey)

• Visualise spatial data • Perform fundamental spatial analyses on vector data such point in polygon operations • Understand and manipulate the outputs of overlay operations • Produce and export maps

You should copy all of the folder Prac2 to your file space and work from that, setting write permissions on the folder and files as you need. In this exercise you will use two datasets: anonymised EMS data from 2007 in Niigata of incidents attended by an Ambulance and 2005 census data. The actual data has been geographical adjusted to protect patient confidentiality. The aim of this study is to explore the spatial relationship between serious and critical EMS cases and age using simple demographic profiling of areas in which the EMS cases originated. 1. Start ArcMap Launch ArcMap by selecting Start > ArcGIS > ArcMap Add the following shapefile data, niigata_2005_01.shp and open EMS_cases_anon.csv The shapefile is in a standard GIS format and has at least 3 component files, but sometimes has as many as 8 associated files. Have a look at the different files in windows explorer. The text file is a simple Comma Separated Variable (csv) file, with field headers and two sets of X and Y attributes (metres and degrees) such as are returned by a GPS. This is a very common form of ‘raw’ data, that needs to be imported into ArcMap and to have its geography made explicit. You will notice that when a text file is loaded into ArcMap, it defaults to the ‘Source’ view showing file paths, rather than the Display view (see the tabs at the bottom of the table of contents).

Open the EMS data (right click > Open) and check that the data is complete and has loaded. Then, right click on the file and select Display XY data. In the next window, make sure that you specify Xm and Ym correctly. Accept the message – this will give the data records an ID. Hint: Common problems in loading csv / text data that you might wish to remember when you import your data to a GIS in future are:

- it is open in another software – e.g. Excel - the field names have characters that are not allowed (simple

text and numbers, no spaces or non-standard characters) - the data has gaps – make sure that each cell has a data entry.

You may wish to use ‘-9999’ for nodata entries - the data is inconsistent with different data types in the same

field (e.g. text in one cell, numbers in another). ArcMap is

Page 2: Practical 2: Spatial Analysis I - University of Tokyo 2 Spatial... · Practical 2: Spatial Analysis I . ... - it is open in another software – e.g. Excel - the field names have

Spatial Analysis I Lex Comber, April 2011

2

lazy and reads the fist few lines and decides what the data type is. This process creates a virtual events layer – EMS_cases_anon events.

Right click > Data > Export Data and save as EMS_cases.shp as the below, specify a coordinate system from the data frame.

Load the file into the project when it has been created. You can then remove the virtual events layer form the table of contents.

The EMS data records the total number of EMS cases that required an ambulance in the period April to December 2007 in Niigata, and includes attributes describing severity of the cases, its location, the unit that was deployed to attend and some other information. The census data was collected in 2005 and includes information on the total population and the number of people of 65 or over. This exercise will explore these 2 datasets, examining the interaction of age, severity of the EMS case and the area from which the patient originated. The aim is to better understand the spatial and demographic distribution of demand for EMS treatment.

• What are the possible shortcomings or limitations of combining these data or integrating them together?

2. Examine the data Visually examine the attributes of each dataset paying specific attention to the Age attribute in the Census data and the Severity descriptor in the EMS data. Now examine the data more formally. Rick click on the Age attribute of the EMS data and select Summarize. Accept the defaults in the next window and click OK. Load the result into the map and examine the summary table that is created. This resultant table shows the counts of each Age.

• Why do you think there are so many EMS cases of Age equal to 0? Do the same for Severity.

Page 3: Practical 2: Spatial Analysis I - University of Tokyo 2 Spatial... · Practical 2: Spatial Analysis I . ... - it is open in another software – e.g. Excel - the field names have

Spatial Analysis I Lex Comber, April 2011

3

Now right click on the Age attribute of the EMS data and select Statistics. A histogram of the age profile is given, showing the skewed distribution towards older people. Examine the census data in the same way. 3. Prepare the Data I It would be useful to know the proportion of the population that are ‘old’ (i.e. 65 or older) in each census area. Create a new attribute called OldProp of type ‘Double’. Open the census data attribute table, then Options > Add Field as below and click OK

Right click on the new field and select Field Calculator. Click the Advanced tab, enter the text below into the window (copy and paste from this document is easiest!) and specify Oldprop = value

Page 4: Practical 2: Spatial Analysis I - University of Tokyo 2 Spatial... · Practical 2: Spatial Analysis I . ... - it is open in another software – e.g. Excel - the field names have

Spatial Analysis I Lex Comber, April 2011

4

VBA script (copy and paste it into the Field Calculator):

Dim value As Double If [Population] <> 0 Then value = [65over] / [Population] Else value = 0 End If

Next, select the “serious”, “death” and “critical” EMS cases to create a new layer. From Practical 1 you should be able to do this. The procedure is summarised here. Selection > Select by Attribute and then complete the dialogue as below.

Chose EMScases as the layer, and then double click on “Severity” then click on “=” so that they are entered into the dialogue box, then click on Get Unique Values and then click on ‘Serious’. Then click on Or and repeat the operation above but using ‘Critical’ and ‘Death’. The result should look like the window to the left. Click on OK The serious and critical EMS cases should be highlighted in the map window (if they are not make sure that the layer is switched on)

Page 5: Practical 2: Spatial Analysis I - University of Tokyo 2 Spatial... · Practical 2: Spatial Analysis I . ... - it is open in another software – e.g. Excel - the field names have

Spatial Analysis I Lex Comber, April 2011

5

Now create a layer from the select features. Right click on the EMScases layer in the table of contents Selection > Create Layer from Selected Features This creates ‘EMScases selection’ which is a virtual layer. To save it off, right click on it Data > Export Data and save it as ‘SevereEMS.shp’ to your filespace, again specifying the data frame as providing the coordinate system.

After this file has been opened into the project, you can remove the virtual file ‘EMS_cases selection’ from the Table of Contents.

Save the project file. Hint: often you will work on a project on multiple computers. To facilitate this you can set the data file paths to be ‘absolute’ or ‘relative’. Absolute data paths are specific data locations (e.g. C:\WorkSpace\GIScourse\Data\lexdata\SevereEMS.shp). If the data paths are absolute then when you try to open the project file and exactly the same file addresses are not found, then the data will not be found by the .mxd project file. A way around this is to set the file paths to be relative

File > Document Properties > Data Source Options > Store relative paths names to data sources

4. Prepare the Data II – summarising over census areas The analysis described above requires the point data of severe EMS cases to be summarised over census areas. Two spatial datasets can be joined based on the geography that their features share. Right click on the census data file (niigata_2005_1) and select Joins and Relates > Join. In the new window, select the ‘Join data from another based on spatial location’ in the top drop down menu. Specify how each point will be associated with each polygon . In this case, choose ‘it falls inside’, and sum as you want the sum of the severe counts in each census area.

Page 6: Practical 2: Spatial Analysis I - University of Tokyo 2 Spatial... · Practical 2: Spatial Analysis I . ... - it is open in another software – e.g. Excel - the field names have

Spatial Analysis I Lex Comber, April 2011

6

Examine the resultant file by looking at the attribute table. You will see that all of the severe EMS data attributes have been ‘summed’ as per the dialogue window above. In this case we are only interested in the ‘Count_’ attribute. This is a count of severe cases in each census area.

Order the ‘Count_’ attribute in descending order (right click on the field and select sort descending). Highlight the record with the highest value as below and then Selection > Zoom To Selected Features It should look something like the below.

Page 7: Practical 2: Spatial Analysis I - University of Tokyo 2 Spatial... · Practical 2: Spatial Analysis I . ... - it is open in another software – e.g. Excel - the field names have

Spatial Analysis I Lex Comber, April 2011

7

• Why are there seemingly fewer cases locations in this census area than indicated by the ‘Count_’ attribute?

Hint: use the identify tool and examine the X and Y attributes of the severe cases data

It would be interesting to visually examine how the number of old people relates to the number of severe EMS cases. This might be an initial look, as part pf hypothesis development in a wider study. So it would be useful to know the spatial distribution of how the factors relates. One way is to look at the number of severe EMS cases per 100 old people. Clear the selection. To do this, create a new variable called SevereRate in the Census_join layer as type double Right click on layer > Open Attribute Table > Options > Add Field and calculate the values using the script below. Again copy and paste! Right click on SevereRate in the attribute table Select Field Calculator, Advanced and specify SevereRate = value in the bottom dialogue box Enter the code below Dim value As Double If [Count_] <> 0 Then

If [65over] <> 0 Then value = [Count_] / ([65over] / 100)

Else value = 0 End If

Else value = 0 End If

Page 8: Practical 2: Spatial Analysis I - University of Tokyo 2 Spatial... · Practical 2: Spatial Analysis I . ... - it is open in another software – e.g. Excel - the field names have

Spatial Analysis I Lex Comber, April 2011

8

Additional exercises Repeat the operations in Section 4 but this time joining the census data to the point data (i.e. right click on severeEMS Joins and Relates > Join > Join data from another layer based on spatial location). Notice the different dialogue window and that the output has data for each EMS point. 5. Visualising the Data and exporting maps In the first practical you exported the data in KML format for easy and quick visualisation on Google Earth. In this part you will generate more formal maps using the census_join and severeEMS layers created in Section 4. You can remove the other data layers from the table of contents if you wish. Organise the data so that the severe cases layer is displayed on top of the census data. You will make 4 maps in different layouts showing the distribution of the severe cases, the proportion of old people in census areas, and the number of census cases in each area. A very simple map can be generated simply from a screen grab (find the ‘Print Screen’ key and click and then paste into a document). This gives the image to the left below. Alternatively you could Export this view to an image file (jpeg, png, tiff, etc). File > Export Map naming the file and setting the resolution to give the image on the right below.

However these do not fulfil cartographic conventions – the scale bar, north arrow and legend are missing. Go to View > Layout View This changes the view to a portrait view. To change this to a landscape view go to File > Page and Print Setup and select the landscape option. The map display is changed but the data may not be centred (below left). Note that you can pan zoom etc in this view as well.

Using the select tool adjust the data frame so that the map fits onto the page (below right)

Page 9: Practical 2: Spatial Analysis I - University of Tokyo 2 Spatial... · Practical 2: Spatial Analysis I . ... - it is open in another software – e.g. Excel - the field names have

Spatial Analysis I Lex Comber, April 2011

9

You will now insert a legend, scale bar and north arrow.

Insert > Legend and in the legend wizard window make sure that both layers are selected as Legend Items

In the next window specify the legend to be ‘Severe EMS cases in Niigata’ and select the defaults in the next windows (you can experiment with these settings at a later date). The Legend box is created and placed in the centre of your map. You can drag it to a suitable location. The legend should look something like the below left. In the table of contents you can change the names of the data that is being displayed and the legend will automatically update. In the layer Properties > General tabs change the layer names to ‘Severe EMS cases’ and ‘Census Areas’. The Legend will update as in the below right.

Now insert a north arrow

Insert > North Arrow and pick one that you like! Again, position this in a suitable place. Next insert a scale bar Insert > Scale Bar and again pick one that you like (I would add that simpler is often more elegant – but this is a personal decision!) Click on Properties to specify the number of division, subdivisions, Units and Label. The scale bar can be dragged to your preferred location. The numbers on the scale bar change when it is re-sized – try dragging the corners. When you are happy with the map, save your .mxd project and export your map. Mine is below.

Page 10: Practical 2: Spatial Analysis I - University of Tokyo 2 Spatial... · Practical 2: Spatial Analysis I . ... - it is open in another software – e.g. Excel - the field names have

Spatial Analysis I Lex Comber, April 2011

10

It is important to show the data attributes and the spatial distribution of their variation. Double click on the census_join layer to open the layer Properties. Go to the Symbology tab and select Quantities. Select OldProp as the value, chose a Colour Ramp ,the number of classes AND how they are defined in the Classify dialogue. In the below I have selected 5 classes defined by Equal Interval. You should experiment with different class numbers and definitions. When you are happy click Apply to see the results. You may wish to turn off the cases layer.

. Note that the legend automatically updates and you may wish to re-position the scale, bar arrow and legend. You can also change the legend caption by clicking on the text in the table of contents and the layer values by entering the payer properties > Symbology Tab, again by clicking on the Label values.

Page 11: Practical 2: Spatial Analysis I - University of Tokyo 2 Spatial... · Practical 2: Spatial Analysis I . ... - it is open in another software – e.g. Excel - the field names have

Spatial Analysis I Lex Comber, April 2011

11

Note the selection of classes is VERY important – compare the two displays below. They are the same data, showing 5 classes, one by Equal Interval (left hand side) the other by Natural Breaks (right hand side). .

or You will now make a map of the number of severe EMS cases in census area. In the Properties > Symbology tab change to show Categories and select the ‘Count_’ attribute to be the Value Field. Click Add All Values and select an appropriate colour ramp and make sure the ,all other values> check is off. Then right click in the category window and select Properties of All Symbols. In the next window set the Outline Color to No Color. Click Ok to close this window and Apply the changes to the map. You will notice that the outlines of the census areas have been removed allowing for very small areas to be easily displayed.

Finally it is possible to zoom into specific areas to highlight particular areas of interest. The maps below show the Number of severe cases in each census area for the whole region and for the central region in detail.

Page 12: Practical 2: Spatial Analysis I - University of Tokyo 2 Spatial... · Practical 2: Spatial Analysis I . ... - it is open in another software – e.g. Excel - the field names have

Spatial Analysis I Lex Comber, April 2011

12

Save your project. 6. Other spatial operations In the final part of this exercise you will be introduced very briefly to some other spatial operations that you might find useful (especially when you have to do your own project). Open a new project and add the following data:

- the shapefile of severe EMS cases that you created above - the file showing ambulance locations in Niigata, ambulance.shp

You will see that I have re-shaded the ambulance stations and made them bigger. You can do this by clicking next to the icon below the name of the layer

It is sometimes useful to identify the number of features in one dataset with a certain distance of features in another. For example, we may wish to know about travel times, catchments, service coverage etc.

Page 13: Practical 2: Spatial Analysis I - University of Tokyo 2 Spatial... · Practical 2: Spatial Analysis I . ... - it is open in another software – e.g. Excel - the field names have

Spatial Analysis I Lex Comber, April 2011

13

In this part of the exercise you will identify the number and location of severe EMS cases that are outside of a specific distance from ambulance locations. Response time to severe EMS cases is a critical factor in patient survival. Best practice guidelines indicate that ambulances should be there within 5 minutes of a critical accident. Your objective is to determine how many severe EMS cases are further away than 5 minutes. Under the assumption that average ambulances travel time is 35km / h, then 5 minutes travel time this equates to a distance of 2917m. Go to Selection > Select by Location You should select the features from serious EMS that intersect the features in this layer ambulance apply a buffer to the features in ambulance of 2917 Meters as below. When you click Apply and then OK, and the features that are selected are highlighted.

Now open the attribute table of the serious EMS cases layer and scroll up and down. You should see that some of the records are also highlighted.

You are not actually interested in this selection but the ones that are NOT selected. To switch the selection, right click on the EMS layer and chose Switch Selection. This inverts the selection.

Page 14: Practical 2: Spatial Analysis I - University of Tokyo 2 Spatial... · Practical 2: Spatial Analysis I . ... - it is open in another software – e.g. Excel - the field names have

Spatial Analysis I Lex Comber, April 2011

14

Now you can create a layer of the cases that are selected as this is your target output. Right click on the EMS layer again and this time chose Create Layer from Selected Features. Clear the selection and turn off the serious EMS layer to examine the layer you have just created. Note: this selected layer is a virtual layer that only exists in your project. If you save the project it will open again but if you want to use this layer in other analyses, then you should save it the normal way Right click > Data > Export Data

• How many EMS cases are more than 5 minutes away from an ambulance station?

• Why might this figure be unrealistic?

You will have noticed that in the selection dialogue there are many ways of selecting features from one dataset relative to their geographic relationships with another. You should examine some of these. End of Practical 2