using gps visualizer to geocode - david mckie gps visualizer to geocode tutorial.pdf · 19.note...

Post on 28-Sep-2020

23 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Using GPS Visualizer to geocode

Geocoding is a process by which individual addresses in a table are plotted onto a map, a process described on page 216 of our textbook, and in subsequent pages. However, this information can’t be plotted without the latitude and longitude coordinates.

In order to add these coordinates, we will have to use on online mapping utility. In this case, the utility of choice is GPS Visualizer.

But first, we have to get the data.

So let’s perform this exercise using a table from our restaurant inspection database that we created in MySQL.

We will export a table of all the Tim Hortons restaurants that had failed inspections, and then use GPS Visualizer to obtain the longitude and latitude coordinates so we can map the locations, including the ward in which they reside.

Let’s get started.

1. Open your MySQL Workbench. 2. We will query the VIEW that we created from the business, inspection and

violation tables in the second MySQL tutorial. We will use the following query to obtain a table of failed Tim Hortons inspections: SELECT Year(date) Year, Name,concat_ws(',',Address,'Ottawa','Ontario','Canada') AS AddressName, Code, COUNT(*) as Inspections FROM restaurant_inspection_master WHERE Name LIKE '%horton%' and score=0 GROUP BY Year, AddressName

order by Inspections desc;

3. With this query, we have grouped all the Tim Hortons inspections by year,

counted the number of inspections, used the WHERE clause to limit the selection to failed inspections (in this case, zero), and then used the concatenation function to combine the street address with the names of the city (Ottawa), province (Ontario) and country (Canada).

4. Now we can export this table as a csv file by clicking on the “Export” button. Be sure you save the file in the folder for this tutorial.

5. Open the csv table.

6. Now we will use Excel’s text-to-column option to separate the address fields

into street address, city, province and country, a process that is explained on pages 97 to 98 of our textbook. You will have to insert three columns for city, province and country.

7. Now use the text-to-column option.

8. Rename the columns. Replace “AddressName” with “Street”. Name column D, “City”, column E “Province” and column F “Country.”

9. Save the file in the csv format. 10. A free Geocoding program like GPS Visualizer will use the information in

columns C,D, E and F to plot latitude and longitude coordinates.

11. Once you’re on the GPS Visualizer home page, select option to, “Geocode multiple addresses”.

12. Choose “Bing Maps” from the drop-down menu next to “Source”.

13. Before pasting our table into the Visualizer’s “Input” area, we will need to get an AppKey for Bing Maps in order to geocode multiple addresses. Click on the “why?” like to get a pop-up box that explains the reason.

14. To obtain your Appkey for Bing Maps, select the “Get a key” tab and follow

the instructions. This previous tutorial for instructions for obtaining the key. 15. Once you have your key, paste it into to the box to the right of the “Your

MapQuest AppKey” prompt. 16. Copy and paste your table from the csv file into the “Input” section. 17. Select “Bing Maps” as the source. 18. Make sure the “tabular (columns & a header)” option is chosen for your

“Type of data”. Your field separator is a comma. Your screen should look

like this.

19. Note that I have blanked out my API key. Your own key should be in that

spot. 20. Select “Start geocoding”. 21. The process to geocode the 142 records will take a few minutes, so please be

patient.

22. Copy and paste the table in the “Results as text” section into Excel.

23. Not only does GPS Visualizer create the latitude and longitude in columns I

and J, respectively, but it also creates a new address field in column K in which it injects the postal code. Now we have an abundance of additional geographic information to place the Tim Hortons’ locations on a map, and combine them with a shape file such as ward boundaries.

24. Now it’s time to map the restaurants using ArcGIS Online. 25. Download the city of Ottawa’s 2014 ward shape file. 26. Log on to ArcGIS Online. 27. Create a new map 28. Upload the ward shape file.

29. Upload the Tim Horton’s file that you’ve exported from MySQL. If you

don’t have it, then click here for the file.

30. Select the ”Inspections” column to display on the map. In step two, you can

select different drawing styles which will allow you to display the number of inspections in various ways, either in different colours, as in step two, or as a heat map, as in step three. Let’s stick with step one for now.

31. Select the DONE tab.

32. Now we want to sum the number of violations in each ward. Hover your

cursor over the Tim Hortons’ lawyer to obtain the icons.

33. Select “Perform Analysis”, Summarize Data and then “Aggregate Points.

34. Step one contains your Tim Hortons csv file; step two contains your ward

file; step three – AND THIS IS THE CRUCIAL STEP – is where we are going to sum the number of violations in each ward (as opposed the number of inspections).

35. From the drop-down menu in the “Field” box, select “Inspections”; in step four, group by “Inspections”. In step five, rename your layer to something

that makes more sense and run the analysis.

36. Now you only have to select the new layer and the ward layer. Open your

new layer’s attribute table the see the result.

37. To change the contents of the legend, hover your cursor over the layer and

select the “Change Style” option once more. 38. Choose the “Sum Inspection” field in step one and the first “drawing style”

option in step two.

39. If you’re happy with the result, select “DONE” to return to the map.

40. You can see the attributes in the pop-up box, which you can reconfigure by

hovering your cursor over the layer and clicking on the three dots (called “More Options”) to the far right of the menu under the layer name, and then choosing the “Configure Pop-up”. Click on the “Configure Attributes” link underneath the box containing the field names.

41. You will obtain a dialog box that allows you to select the fields you want to display.

42. Only choose the categories you want. Save the result to return to the map. 43. Check out the result.

44. You’ll notice that the pop-up box also a bar chart that COUNTS the number

of inspections for each ward.

45. Once you return to the map, hover your mouse over the layer to obtain the “Legend” icon.

46. If you want to add more categories you can return to the “Change Style”

option, click on the “drawing style” that you’ve used and to obtain options.

47. Click the box to the left of “Classify Data” if you want to increase the categories of Sum Inspections”

48. Let’s increase the classification to five and select OK and DONE to return to

the map.

49. We can return to the drop-down menu from the “More Options” choice

under our Tim Hortons layer to obtain the “Choose Labels” option. Delete

“NAME”.

50. Click the “+” sign to the right of the “Text” box to obtain the list of column

labels.

51. Scroll down and select “WARD_EN”, and then, OK.

52. If we’re happy with this result, we can “Share” the result to obtain the

embed code needed to place the map in our blog post. 53. Save the content. 54. We can also export this table as a csv file to continue our analysis, which

could include using another visualization tool such as Google Fusion Tables to also display the result as a bar graph, or creating simple pivot table in Excel.

55. Choose “Manage Data” option from your Analysis options we’ve been using in this tutorial.

56. Select Extract Data.

57. Feel free to rename the file in step four. 58. Run the analysis.

59. Select OK. And return to My Content to see the lawyer.

60. Hover your cursor over the “Extract Data” layer, click on the drop-down arrow to the right and download the file, and transfer it to the folder you’ve been using for this tutorial.

61. In order to obtain the layer’s embed code, you MUST make the map PUBLIC.

62. To complete this process, return to the layer, and click on the “Share” icon above the map.

63. Making it public will give you an embed code.

64. Select the options you want, and then copy the code and embed it into your

blog post. 65. Click here to see my example. It might take a few seconds to load, so please

be patient. 66. So we have gone from a file in MySQL, to geocoding in GPS Visualizer, to

an analysis in ArcGIS Online that has counted the number of inspected Tim Hortons restaurants in city of Ottawa wards.

67. Congratulations. Well done!

top related