PROC GEOCODE: Finding Locations Outside the U.S.

[Pages:31]PROC GEOCODE: Finding Locations Outside the U.S.

Darrell Massengill and Ed Odom, SAS Institute Inc., Cary, NC

ABSTRACT

How do you convert addresses into map locations? This is done through the process of geocoding. PROC GEOCODE was first included in SAS/GRAPH 9.2 to provide this capability. Street-level geocoding for the United States was later added to the third maintenance release of SAS 9.2 (9.2M3). This paper will review all of the capabilities of this procedure including the new abilities to geocode international cities added in SAS 9.3M2 and Canadian street-level geocoding available in SAS 9.4 Also, you can now import free postal code data for Great Britain and Australia for geocoding in all releases of PROC GEOCODE.

CONTENTS

Abstract Introduction Geocoding Basics City Location Postal Code Location ZIP+4 Location Street-level Location IP Address Location Geocoding Method Selection PROC GEOCODE Overview Procedure Syntax Lookup Data

CITY SAS 9.2 - 9.3M1 SAS 9.3M2 - 9.4

ZIP U.S. ZIP codes Great Britain Postcodes Australian Postcodes Canadian Postcodes Other Countries

ZIP+4 From SAS From Melissa Data

Lookup Data (cont'd.)

STREET SAS 9.2 - 9.3M2 SAS 9.4

RANGE

CUSTOM

Examples

CITY SAS 9.2 - 9.3M1 SAS 9.3M2 - 9.4

ZIP U.S. ZIP Codes Great Britain Postcodes Australian Postcodes

ZIP+4 From SAS From Melissa Data

STREET United States Canada

IP Address

CUSTOM

Summary

Resources

Contact Information

Appendix 1 - ZIP Code FAQ

Appendix 2 - SAS Spatial Capability Summary

PROC GEOCODE: Finding Locations Outside the U.S. Page 1

INTRODUCTION

Every organization has large amounts of data that include location components ranging from a city name, postal code or a complete mailing address. The address data is useful only if it is transformed into a geographic location that can be viewed on a map, used in distance calculations or various spatial analyses. To make this data useful, you must convert the address to a location by determining its latitude and longitude. This conversion process is called geocoding. For IP addresses the process is also known as geolocation. This paper will discuss geocoding using the SAS/GRAPH GEOCODE Procedure. First, we will introduce the concepts needed to understand geocoding, and then we will discuss PROC GEOCODE's traditional and new functionality. Finally, examples will show how to use PROC GEOCODE.

GEOCODING BASICS

The geocoding process depends on lookup data with the necessary information to convert an address to a geographic location. This data is the key to geocoding. Factors such as age and granularity of the lookup data determine the geocoding results. Addresses routinely change because of commercial or residential construction, new streets, and postal codes being split and changed. As a general rule, use the most recent lookup data containing new streets and the latest corrections. However, when geocoding data from a specific year, it may be better to use lookup data for that year. Granularity is another important consideration. Does the location need to be the actual house position or will a more generalized location be close enough? For example, when viewing geocoded addresses on a state or U.S. map, a ZIP code or city centroid is accurate enough. There is no visible difference between a point placed on Elm Street and another on Turner Drive in Houston when viewed on a statewide map of Texas. To understand geocoding, it is important to first understand the lookup data. It is particularly important to understand the differences between ZIP code data, ZIP+4 data, street address data and city center data. IP address data is completely different from the other types of addresses, but it is important to understand this data, too. Another factor to consider when choosing a geocoding method is your input data. What address components does it contain? For example, do you have the complete mailing address including house number, street name, city, state and ZIP code, or do you have only parts of the full address? Also, the quality and consistency of your data impacts the geocoding process. If your addresses contain extraneous information such as suite or floor numbers, it may cause parsing difficulties for the geocoder.

CITY LOCATION

Of the various geocoding methods, the most generalized location is by city name. This is perfectly adequate for locating points over a large geographic area, for example addresses spanning a large nation such as Canada. City geocoding requires more than just a city name. At a minimum the city and state or province names are needed as city names are not unique. For example there are three cities named San Francisco within the U.S. Without specifying a state, it is impossible to determine which one is wanted. For that same reason, a country name is also required when geocoding international cities as there are at least 88 cities named San Francisco across the globe.

PROC GEOCODE: Finding Locations Outside the U.S. Page 2

POSTAL CODE LOCATION

After city locations, the next more precise geocoding method is by postal codes which are used in many countries to define mail delivery routes or locations. The codes vary in length and can contain a mix of alphabetic characters, numeric digits and spaces. In the United States, postal codes are called ZIP codes and contain five digits. In this paper, ZIP code and postal code are used interchangeably. While most ZIP codes apply to a set of specific streets in an area, some are assigned to a single building or to a post office. Boundaries between ZIP codes are not created by the U.S. Postal Service (USPS). ZIP codes are not officially defined polygonal areas in the manner of a county or city boundary. Creating polygons by simply enclosing the linear delivery routes would leave gaps between the polygons because there are large, undeveloped areas. The area covered in a ZIP code varies by its population density. A rural ZIP code covers a larger area than one in a city. As noted, some ZIP codes apply to only a single building. Generally, ZIP code address data specifies a centroid location for the ZIP code area. Because those ZIP boundaries are generated by different data vendors, their centroid locations often vary. Appendix 1 discusses frequently asked questions about ZIP codes. Figure 1 illustrates an artificial boundary created to enclose the streets in a ZIP code. When geocoding addresses having this ZIP code, all are assigned the latitude and longitude of the polygon's centroid. This behavior also applies to non-U.S. postal codes.

Figure 1. Boundary Around Streets with Common ZIP Code So, when geocoding an address by its ZIP code, the location will be in the general vicinity of the address, but likely not on the actual street.

PROC GEOCODE: Finding Locations Outside the U.S. Page 3

ZIP+4 LOCATION

A U.S. ZIP code is also subdivided into smaller delivery routes which are tagged with a ZIP+4 identifier. A hyphen and four additional digits are appended to the ZIP code to specify these additional subdivisions. A ZIP+4 will likely represent a single street or a part of a street. In a high-density urban area, it might represent one side of a street on a single block or even one floor of a large building. Figure 2 illustrates the relationship between a ZIP code and one of its ZIP+4 segments. The ZIP+4 centroid is at the midpoint of that street segment. Centroids are computed for each ZIP+4 in a ZIP code. Any address within a ZIP+4 would be assigned that centroid if geocoded by ZIP+4 data.

Figure 2. ZIP+4 within a ZIP Code Area While a ZIP code will get you to the general vicinity of an address, ZIP+4 geocoding will probably get you to the correct street in the address.

PROC GEOCODE: Finding Locations Outside the U.S. Page 4

STREET-LEVEL LOCATION

The most precise location method is street-level geocoding using the full mailing address: house number, street name, and either ZIP code or city and state. This does not necessarily place the geocoded address at the exact house location. It approximates the position of a particular address on a street by assuming that house numbers are an equal distance apart, which might not be true. But it is still a more precise location than placing the geocoded point at the centroid of a ZIP code or city. As Figure 3 illustrates, a street-level location is placed along the given street as near the exact structure as possible given the limitations of the lookup data. If you have ever looked up your home address on the Web, it is likely that the location did not align exactly with your house. That precision is a characteristic of the lookup data available. However, the geocoded location was close enough for most uses.

Figure 3. Location using House Number and Street Name

IP ADDRESS LOCATION

Unlike street addresses, IP addresses were not designed to be geographic. Generally, these are collected from visitors to Web sites and indicate the connection the visitor used. IP address lookup data contains information that matches ranges of IP addresses to particular geographic locations. The location found will not be at the street or even ZIP code level, but might indicate the city, state, or country where the IP address is registered.

PROC GEOCODE: Finding Locations Outside the U.S. Page 5

GEOCODING METHOD SELECTION

Several factors must be considered when choosing the appropriate type of geocoding: 1. Geographic Extent If the data to be geocoded spans a large region, the extra precision of street-level geocoding may not be required. ZIP code or possibly even city geocoding may be sufficient for your needs. 2. Attribute Values Wanted Do you want to assign values to your data based on the geocoded locations? For example, the street geocoding method can also assign Census Tract numbers to your addresses. 3. Location Precision This is related to both the Geographic Extent and Attribute Values Wanted parameters discussed above. More precise locations may be required when your data is in a smaller area or if you want to assign attribute values that require precise locations. 4. Address Components Present The geocoding method also depends on the content of your input data. If your data lacks street names, then street-level geocoding is not possible. You would have to augment your input data or geocode it by ZIP or city. 5. Lookup Data Availability You must have the appropriate lookup data covering the geographic extent of your addresses. For example, if you do not have postal code or street-level lookup data for a region, you cannot use those geocoding methods for addresses there. The cost and disk space required for the lookup data can also be a factor.

PROC GEOCODE can also do multiple types of geocoding in one run. For example, if the STREET method is specified as the primary geocoding process and an address is not matched, the geocoder will pass that address to the ZIP method. If the ZIP method cannot match the address, the CITY method is then tried. This cascading into the next geocoding level is the default behavior which can be disabled if desired.

PROC GEOCODE: Finding Locations Outside the U.S. Page 6

PROC GEOCODE Overview

The GEOCODE procedure computes geographic coordinates (latitude and longitude values) from address data. These geographic coordinates can then be plotted on a map, used for distance calculations or in spatial analyses. Appendix 2 contains more information about what can be done with the geocoded coordinates. In addition, the procedure enables you to add attribute values from your lookup data to the geocoded locations. Examples would be adding Census Tracts or area codes to a geocoded address.

The six methods of geocoding and currently available lookup data sources are listed in Table 1. Some of the lookup data are install with SAS, some can be downloaded from the SAS MapsOnline web site, some is freely available from third party providers, and some must be purchased. For the third party suppliers listed, SAS provides a program to import their data into geocoding lookup data sets.

Not all of the lookup data in Table 1 is available for all releases of PROC GEOCODE. For example, the CITY method lookup data in the MAPSGFK library was added in the second maintenance release of SAS 9.3 (9.3M2). And the Canadian STREET lookup data from GeoBase is available only for SAS 9.4 and will not work with earlier SAS releases.

Geocoding Method

CITY

ZIP PLUS4 STREET RANGE CUSTOM

Input Data

Coverage

Lookup Data Source

City and state name

United States World

MAPSGFK.USCITY_ALL SASHELP.ZIPCODE

MAPSGFK.WORLD_CITIES WORLD_CITIES_ALL

United States

SASHELP.ZIPCODE

Postal code

Australia

Australian Bureau of Statistics

England and Scotland

Ordnance Survey of Great Britain

ZIP code with ZIP+4

United States

MapsOnline Melissa Data

Complete mailing address

United States Canada

MapsOnline Census TIGER shapefiles GeoBase National Road Network

IP address

World

MaxMind

User-defined region

n/a

Table 1. Geocoding Methods and Lookup Data

User created

By default if the primary method specified cannot geocode an address, the procedure attempts to geocode it with the next (less precise) method. For example, if you specify street geocoding and no match is found, the procedure will try the ZIP method. If that fails to find a match, it then tries the city method. This cascading method behavior can be turned off if desired.

PROC GEOCODE: Finding Locations Outside the U.S. Page 7

The _MATCHED_ variable in the output data set indicates the type of match that was found for each address. Values are listed in the PROC GEOCODE documentation. The GEOCODE procedure requires two types of SAS data sets:

The first is an input data set of addresses to geocode. This data set will contain variables related to the address such as street address, city, state, and ZIP code. Note that it is important for this data to be clean and in the proper form in order to have the best match rate.

The second type is one or more lookup data sets that are needed to transform your address data into

geographic locations. The number of data sets depends on the geocoding method. ZIP, PLUS4 and CUSTOM geocoding each use one lookup data set, IP address geolocation uses two, and street-level references six. The simplest example illustrating how these data sets are used is with ZIP code geocoding and its single lookup data set. Figure 4 shows that all of the variables from your input data are carried forward into the output data set. The ZIP variable as the geocoding key is found up in the lookup data set and those LONG and LAT values are added to the output data set. These are the geographic coordinates of that ZIP code centroid. In addition, if the lookup data set contains other attributes such as county names or Census Blocks, you can specify that these additional values also be moved to the output data set. The processing for other geocoding methods is a bit more complicated, especially street level.

Figure 4. ZIP Code Lookup Process

PROC GEOCODE: Finding Locations Outside the U.S. Page 8

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download