Geocoding Crashes in Limbo Carol Martell and Daniel Levitt Highway Safety Research Center, Chapel Hill, NC

Similar documents
Google Earth Tutorial 1: The Basics of Map-making in Google Earth 6.2

ET01. LIBNAME libref <engine-name> <physical-file-name> <libname-options>; <SAS Code> LIBNAME libref CLEAR;

The GEOCODE Procedure and SAS Visual Analytics

Google Earth II: Create a tour with Google Earth

Macro Method to use Google Maps and SAS to Geocode a Location by Name or Address

A Macro that Creates U.S Census Tracts Keyhole Markup Language Files for Google Map Use

Completing Baseline s Site Survey Request Form

Instructions: Turning Your Spreadsheet of Information into a Google Earth Layer

ArcMap and Google Earth

Mississippi Public Schools 2015

Overview. Setting Up. Geospatial Centre University of Waterloo November 2015

Geodatabases. Dr. Zhang SPRING 2016 GISC /03/2016

NAACCR Geocoding Tutorial

MS2. Modern Traffic Analytics ms2soft.com

PlaceMap. Accommodation. Slide 1

Address Management User Guide. PowerSchool 8.x Student Information System

A Dynamic Imagemap Generator Carol Martell, Highway Safety Research Center, Chapel Hill, NC

Instructions for Getting Data into Google Earth

The Data Journalist Chapter 7 tutorial Geocoding in ArcGIS Desktop

1. Start ArcMap by going to the Start menu > All Programs > ArcGIS > ArcMap.

GIS link to the Web of Things

Google Earth Pro: A tutorial

Matching GPS Records to Digital Map Data: Algorithm Overview and Application

WOMEN'S INTERAGENCY HIV STUDY SECTION 40: GEOCODING PROTOCOL

How to determine latitude and longitude values for an address that is not found

Data to App: Web,Tablet and Smart Phone Duane Griffith, Montana State University,

It s not the Yellow Brick Road but the SAS PC FILES SERVER will take you Down the LIBNAME PATH= to Using the 64-Bit Excel Workbooks.

Overview of the EMF Refresher Webinar Series. EMF Resources

Overview. Setting Up. Geospatial Centre University of Waterloo May 2014

Address Management User Guide. PowerSchool 6.0 Student Information System

A Google Earth User Manual for Earth Science Teachers

Lazy Programmers Write Self-Modifying Code OR Dealing with XML File Ordinals

KML Macro: Integrating SAS and Google API. Mapping Manitoba's Health Data. and Its Application in. on Google Earth and Google Map

Quick-Ticket Guidelines

Store Locator for Magento 2. User Guide

Geocoding vs. Add XY Data using Reference USA data in ArcMap

Importing a txt or csv file into ArcGIS Online [AGO]

Introduction to Google Earth

In order to follow this set of directions you will need the following

TRACS ELECTRONIC CRASH REPORTING FOR LONG FORMS ONLY INSTRUCTIONAL MANUAL

Quick and Efficient Way to Check the Transferred Data Divyaja Padamati, Eliassen Group Inc., North Carolina.

Jeff Moon Data Librarian & Academic Director, Queen s Research Data Centre. What is OpenRefine?

From data source to data view: A practical guide to uploading spatial data sets into MapX

Mapping with Google Fusion Tables

The New American FactFinder N E W F U N C T I O N A L I T Y B U T S O M E Q U I R K S

IMAP MANUAL AN INSTRUCTIONAL GUIDE TO VIEWING AND MAPPING DISTRICT POLYGONS ONLINE LAST UPDATE: June, 2013

OpenRefine. a free, open source, powerful tool for working with messy data

ArcGIS Online. Overview. Setting Up

SAS Visual Analytics Environment Stood Up? Check! Data Automatically Loaded and Refreshed? Not Quite

Excel To KML - Display Excel files on Google Earth.

STORE LOCATOR USER GUIDE Extension version: 1.0 Magento Compatibility: CE 2.0

Geocoding for Beginners. November 18, 2013 Christine Murray University of Pennsylvania, Van Pelt Library

+ Make it from the satellite images in sale, (Easier & Faster, but not always available) (It does cost much. An astronomical number!

Legionnaires GIS. Legionnaires' GIS User Guide

NAACCR Webinar Exercises. May 6, 2010 Kevin Henry Francis Boscoe

- Hold down the 'Shift' key and click and drag the mouse to create a red box which will zoom to that area when released.

Geocoding Reference USA data in ArcMap 10.1

Help Documentation. Copyright 2007 WebAssist.com Corporation All rights reserved.

Explore some of the new functionality in ArcMap 10

Corporation. Once the required parameters have been entered, mouse click Generate KML File and the Path LOS buttons.

Obtaining Aerial Images from Google Earth

HCA ArcGIS. Online Tool - How To Guide V1.0 2/15/2016 HAWAII CONSERVATION ALLIANCE AGOL

4/7/2009. Model: Abstraction of reality following formal rules e.g. Euclidean space for physical space

ArcGIS Online Tutorial

100 THE NUANCES OF COMBINING MULTIPLE HOSPITAL DATA

Extending the Scope of Custom Transformations

Technical Paper. Using SAS Studio to Open SAS Enterprise Guide Project Files. (Experimental in SAS Studio 3.6)

Chapter 6. Building Maps with ArcGIS Online

Georeferencing Protocol KUMIP

ArcGIS Online (AGOL) Quick Start Guide Fall 2018

Lucas County Engineer s GIS Maps User Guide

Geocoding Reference USA data in ArcMap 9.3

Using ArcGIS Online GARP A tutorial on how to use ArcGIS Online to create useful maps! Create By: Ashley Eaton

National Register of Historic Places: GIS Webinar Cultural Resource GIS Facility National Park Service June 2012

Easy Mapping with Google

Open Source Cloud Map User Guide

Ilham Marsudi Universitas Negeri Yogyakarta Yogyakarta, Indonesia

A Generalized Macro-Based Data Reporting System to Produce Both HTML and Text Files

SAS Viya 3.2: Self-Service Import

Google Earth. Tutorials. Tutorial 2: Annotating Google Earth

SAS Report Viewer 8.3 Documentation

Utilizing the VNAME SAS function in restructuring data files

Data Acquisition using Mashup and 3-D Technology. Matt Rahr College of Agriculture and Life Sciences University of Arizona

Making and Sharing Digital Community Asset Maps Using Free Software and Web Resources

Data Representation. Variable Precision and Storage Information. Numeric Variables in the Alpha Environment CHAPTER 9

ColdFusion and SAS : No Pain Meds Required Carol Martell, UNC Highway Safety Research Center, Chapel Hill, NC

STORE LOCATOR PLUGIN USER GUIDE

Road Safety Audit Report Completion Procedure

User Manual. Version 2.0

Create CSV for Asset Import

Part 2: Build your own Map Tour with ArcGIS Online

XML Processing & Web Services. Husni Husni.trunojoyo.ac.id

XML in the DATA Step Michael Palmer, Zurich Biostatistics, Inc., Morristown, New Jersey

Google Earth Maps. Creating an Outdoor Location Using Google Earth. Understanding Geographical Coordinates for Google Earth CHAPTER

POInspect0r. for RNS 510 and Discover units Personal POI. Quick Start Guide

How to calculate population and jobs within ½ mile radius of site

Create a Format from a SAS Data Set Ruth Marisol Rivera, i3 Statprobe, Mexico City, Mexico

Special layers are located at the top of the list. Currently there are four special layer types:

SAS Business Rules Manager 1.2

Tips on Excel. Discover some tips to organize and lay out your Excel file and convert it into a CSV or PDF file.

Transcription:

Paper RIV-09 Geocoding Crashes in Limbo Carol Martell and Daniel Levitt Highway Safety Research Center, Chapel Hill, NC ABSTRACT In North Carolina, crash locations are documented only with the road names for the nearest intersection. Some projects require more accurate location for importing into ArcGis. We use a combination of SAS and GoogleEarth to more accurately pinpoint crash locations. This paper discusses how we streamline a manual process to make it feasible. INTRODUCTION Manually geocoding data points is both painful and time-consuming. We eagerly await the day when crash reports include a lat/long reading. Until then, what we have in North Carolina is a commonly used legacy system that locates crashes relative to the nearest intersection. Recently, some projects have needed to exactly locate pedestrian crashes. A verbal description of the crash, a diagram of the setting, and the intersection-referencing information provide the hints we need to pinpoint the crash locations. Since many pedestrians are hit in parking lots and other non-roadway locations, we need the extra value provided by Google Earth. Google Earth provides the ability to see buildings, parking lots, and other landmarks referenced in the crash narratives. We are able to match the diagrams and descriptions in the data with the photographic evidence visible in Google Earth. We use SAS to send information through various processing tools that ultimately give us a spreadsheet of XY coordinates we can import into ArcGIS. PROCESS OVERVIEW We use the new Google Earth API V3 key to request coordinates of the reference intersection for each crash. Using these coordinates we create a KML file containing a placemark for each crash. Viewing the KML in Google Earth, we use the crash narratives, diagrams, and data to nudge each placemark into the correct location. The resulting saved KML file is then parsed with SAS to extract the corrected coordinates and write a spreadsheet for import into ArcGIS. REQUESTING COORDINATES FROM GOOGLE EARTH The free Google Earth API key allows a user to request geographic coordinates for an address. There are a variety of ways to send the request. We have used the deprecated API V2 service which can provide the results in CSV format. The latest version (V3) returns the results in XML. We use V3 in this paper. Google Earth returns a plethora of information in the XML, but we are only interested in the latitude and longitude readings. Consequently, we parse the XML rather than build a SAS XMLmap. We start with a table having one row for each crash containing the street names for the nearest intersection. We use the URL filename access method to send a geocoding request for each row in the table. filename x URL "http://someplace.com/whatever"; First we construct the request for a URL filename from which to read the results. The required parameters are the address and the API key. We store the URL for the request, along with the API key, both of which will never change, in a variable: str='http://maps.google.com/maps/api/geocode/xml&key=myapikey&address='; The address for geocoding will vary from record to record, and should look something like this: Martin Luther King at Estes Drive, Chapel Hill, NC We replace the spaces with + for the request: Martin+Luther+King+at+Estes+Drive,+Chapel+Hill,+NC Then we concatenate the address variable by variable onto the end of our request string: 1

str=trim(str) trim(left(translate(on_rd,'+',' '))) ' at '; str=trim(str) trim(left(translate(from_rd,'+',' '))) ' at '; When we have finished, the variable str will contain the entire request string, stored as a variable in a SAS table. We can now construct a macro that will read one record from this table, send a geocoding request, parse the results, and insert a row into our final results table. We will loop through the macro, reading each record in turn. First we build the empty results table: create table latlong (id num(8), on_rd char(50), from_rd char(50), lat char(15), long char(15)); We get a count of intersection for the upper bound of our loop: select count(*) into :nrecs from intersections; We begin construction of the macro. We store the Google Earth request string and other desired identifying information in macro variables: %macro getaddr; %do i=1 %to &nrecs; set intersections(obs=&i firstobs=&i); call symput('str',str); call symput('id',id); call symput('on_rd',on_rd); call symput('from_rd',from_rd); We begin a data step that makes the geocoding request and parses the results: filename x URL "%str(&str)"; infile x; We know the latitude and longitude readings are nested within the <location></location> tags like this: <location> <lat>35.9351960</lat> <lng>-79.0561319</lng> </location> This code locates and extracts the two readings, storing them in macro variables: do until (index(_infile_,'<location>')>0); lat=scan(_infile_,-2,'<>'); call symput('lat',lat); long=scan(_infile_,-2,'<>'); call symput('long',long); We needn t read anymore from the XML now that we have our information, so we quit the data step. 2

stop; Now we have our values to insert into the table we prepared: insert into latlong (id,on_rd,from_rd,lat,long) VALUES (&id,"&on_rd", "&from_rd", "&lat", "&long"); We have finished processing one table row, so we end the macro loop and end the macro: % %mend getaddr; WRITING THE KML FILE Using the information in our table named latlong, we write a KML file, which is an XML file specification used to display geographic data in Google Earth. Here is a very simple KML file for a single placemark: <?xml version="1.0" encoding="utf-8"?> <kml> <Document> <Placemark> <name>sample Placemark</name> <Point> <coordinates>-79.05613199999999,35.93519600000001,0</coordinates> </Point> </Placemark> </Document> </kml> We need the Placemark section to repeat for each intersection, or row, in our SAS table. We would like to have the road names included as descriptive data. These can be placed within a <description> tags for each placemark. The opening tags, <?xml >, <kml>, and <Document> are written at the beginning of the program using the _n_=1 conditional logic. Since we ll need to write closing tags, we include the end= parameter with the set statement. The altitude for each placemark will always be zero, so we assign the value 0 to the variable ht: set latlong end=eof1; file "SESUG2010.kml"; if _n_=1 then do; put '<?xml version="1.0" encoding="utf-8"?>' / '<kml>' / '<Document>'; ht=0; We use this code to write a placemark for each row in the table: put '<Placemark>'; put ' <name>' id '</name>'; put ' <description>'; put '<![CDATA[' on_rd 'at ' from_rd ']]></description>' ; put '<Point><extrude>1</extrude><altitudeMode>relativeToGround</altitudeMode>'; put '<coordinates>' long +(-1)',' lat +(-1) ',' ht '</coordinates> ; put </Point>'; put '</Placemark>'; 3

We look for the last record in order to write the closing tags and finish our data step: if eof1 then put '</Document></kml>'; We now have a kml file to open in Google Earth. Figure 1 Figure 2 Figure 3 Figure 1 reveals both placemarks, each revealing the ID for the crash. Zooming in on one of them (Figure 2), we can see the details of parking lots, buildings and other information that will help place the crash more precisely, given the information we may have for the crash. Figure 3 shows the results of clicking the placemark; this reveals the information contained in the description tag section for the placemark. Right-mouse-clicking and selecting properties for a placemark puts it in a mode that allows it to be moved around using drag-and-drop. After all the placemarks have been properly positioned, we save the KML file. FROM KML TO ARCGIS Version 9.3 of ArcGIS allows the import of KML to a geodatabase through the Data Interoperability Extension. Absent that latest version, there are other minimal-effort possibilities. It is now possible to open XML in Excel, save a copy in.xls format, and import the spreadsheet as xy coordinates into ArcGIS. For demonstration purposes, we show how the KML can be parsed with SAS to extract the values, and written to Excel for import into ArcGIS. We re not interested in anything in the kml file before the first placemark, so we again use _n_=1 processing logic: data crashes; infile "SESUG2010.kml" ; if _n_=1 then do until (index(_infile_,"<placemark>")>0); input ; Now we begin to look for the first line containing information we need, which is the <name> tag. The crash identifier is found between the tags. Here we show the KML followed by the SAS code to extract the id value: <name>1234567890 </name> 4

do until (index(_infile_,"<name>")>0); id=input(scan(_infile_,-2,'<>'),10.); Coordinates appear after the name. We extract the two coordinate values from the KML text and output the record: do until (index(_infile_,"<coordinates>")>0); input ; lat=input(scan(_infile_,-3,'<>,'),10.7); long=input(scan(_infile_,-4,'<>,'),11.7); output; We now have a SAS table containing the corrected latitude and longitude. Absent SAS Bridge to ESRI, we write an Excel file for import into ArcGIS as XY values: libname a "crashes.xls"; data a.crashes; set crashes; libname a clear; CONCLUSION We have demonstrated a process to streamline a very time-consuming but valuable task. Being able to exactly place the crashes makes it possible to determine the most common types of pedestrian crashes, leading to potential treatments and other countermeasures that could save lives. CONTACT INFORMATION Your comments and questions are valued and encouraged. Contact the authors at: Carol Martell Highway Safety Research Center 730 Martin Luther King Jr Blvd Chapel Hill, NC 27514 carol_martell@unc.edu Daniel Levitt Highway Safety Research Center 730 Martin Luther King Jr Blvd Chapel Hill, NC 27514 dlevitt@hsrc.unc.edu SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. indicates USA registration. Other brand and product names are trademarks of their respective companies. 5