How to add latitude and longitude coordinates to a point layer if the attribute table does not include that information
Question: I want to calculate the great circle distance between geocoded cancer cases and the hospital facility where the case was first diagnosed, using the SAS Distance Calculator developed by the North American Association of Central Cancer Registries (NAACCR) GIS Committee (available from: http://www.naaccr.org/gis). ESRI ArcGIS 9.1 Data & Maps DVD includes a data set that maps a point for each hospital facility, and that also includes the American Hospital Association identification code number and some attribute data about each facility. However, this attribute table does not include the latitude-longitude coordinates. How do I calculate and add the latitude and longitude information for each facility to the attribute table? I would like to be able to export an attribute table with the latitude-longitude information as a dbase file, which I then could import directly into various other software programs (and/or convert for use by those software programs with data conversion/transformation utilities).
Cautions The ESRI Arc GIS 9.1 Data & Maps DVD landmarks folder includes two different hospital data sets. The ghospitl data set includes 9940 records from the United States Geological Survey Geographic Names Information System (GNIS). The name of the facility is included, but the American Hospital Association identification number is not included. The US hospitals data set includes 5,944 records from the FY2001 American Hospital Association Annual Survey. The American Hospital Association identification number is included.
Redistribution Rights For information about including ESRI data in other analyses or sharing the data with others, see: a) the Help Redistribution Rights HTML summary table included on the ESRI Arc GIS 9.1 Data & Maps DVD; and b) the metadata listed under Description, Data Storage and Access Information, Constraints on Accessing and Using the Data. The ghospitl data set has redistribution rights categorized as Yes 4. Public domain data from US government is freely redistributable with proper metadata and source attribution. The ESRI US Hospitals data has redistribution rights categorized as No. This data set is for Internal Use Only by licensed ESRI End Users. No redistribution rights are granted by the data vendor, and the data is for the end user's own internal use only. ESRI (End Users) shall not use the Health Forum, L.L.C. Data to rank hospitals in a report card context, or be used for regulatory purposes to determine compliance, claims acceptance, or claims verification.
Some Potential Answers Answer 1. For ESRI ArcGIS users, by David Stinchcomb, National Cancer Institute. Answer 2. For MapInfo Users, by David O Brien, Alaska State Cancer Registries. Answer 3. Sample screen shots illustrating the Answer 1 approach, for beginner ESRI ArcGIS users.
Answer 1. For ESRI ArcGIS users, by David Stinchcomb, Health Statistician / Geographer, National Cancer Institute It is relatively easy to add Latitude and Longitude columns to the attribute table for any point layer: * Right-click on the layer, select Open Attribute Table * Use Options -> Add Field... to add two fields, one for Lat and one for Lon, setting the Type to "Double" * Right-click on the column heading for the new Lat field, select Calculate Values...; click Yes in response to the pop-up message about calculating outside an edit session * Click Advanced * At this point, you can click Help and you will see examples of various VBA code segments. We'll use the one for the coordinate of a point. * Copy/paste the code to the "Pre-Logic VBA Script Code" window * For the latitude, we need the Y coordinate so you will need to change the last line to "Output = ppoint.y". The code should look like this: Dim Output As Double Dim ppoint As IPoint Set ppoint = [Shape] Output = ppoint.y * Type "Output" in the bottom window labeled "Lat =" and click OK * Repeat the Calculate Values steps for Lon, this time using the X coordinate (change the last line to "Output = ppoint.x") From here, you can export the table as a DBF file or a text/csv file that can be importing into SAS for the great circle distance calculations. One caution: the ESRI hospital layer may not include all hospitals and some of the locations may be out of date.
Answer 2. For MapInfo Users, by David O Brien, Alaska State Cancer Registries. Answer 2. For MapInfo users, the process is similar but shorter. -Create your two new columns for latitude and longitude under TABLE>MAINTENANCE>TABLE STRUCTURE. Set data type to floating decimal. -Go to TABLE>UPDATE COLUMN, select your table name and column name. In the Value box, click on the "Assist" command button. -In the new "Expression" dialog box that appears, click on the down arrow in the Functions pick list. Choose CentroidY for latitude and CentroidX for longitude. - If you don't want negative longitudes, remember to multiply the function by (-1). - Click OK and run the update.
Answer 3. Sample screen shots illustrating the Answer 1 approach, for beginner ESRI ArcGIS users. Answer 3 is the same as Answer 1, except Answer 3 provides sample screen shots.
Open ArcCatalog and migrate to the computer drive with the ESRI DVD data.
Choose the USA data folder on the DVD
Choose the landmarks folder
Choose the US Hospitals data (hospitals.sdc)
Select the preview tab
Set Preview to Table and see that AHA_ID code is included
Scroll through the attribute table to verify that the table does not include latitude longitude coordinates for hospitals.
Drag the US Hospitals data from ArcCatalog to ArcMap
In ArcCatalog, migrate to the Census folder, then drag the detailed county boundary data to ArcMap
In ArcMap, right click on the hospital data layer (which is read only) and then select Data, Export Data, save Hospital01.shp in a folder, and add to ArcMap. The Hospital01.shp data is a copy that can be edited.
Add the exported Hospital01.shp to ArcMap as a layer, then remove the original Hospitals data layer dragged from the DVD.
Repeat the data export process for the detailed county file shape file, and add the exported Cnty01.shp file to ArcMap.
Right click on the Hospital01 layer, and select Open Attribute table. At the bottom of the attribute table, select Options, then Add Field. Name the field Xcoord, set type = double, precision =20, and Scale =6. Then, select OK.
Repeat the Add Field process to add a column named Ycoord.
Close or downsize the Hospital01 attribute table. In ArcMap, if you have not already added the Editor Toolbar, add the Editor Toolbar. On the Editor Toolbar, select Start Editing. If ArcMap includes several layers, specify Hospital01 as the layer to be edited. Then, open (or re-size) the Hospital01 attribute table, and click on the Xcoord column name (to select this column for editing).
Right click on the Xcoord field, select Field Calculator, and then check the Advanced box.
Click on Help
Select and then copy and paste the 4 lines of Visual Basic Code to add the X coordinates of points into the topmost box in the Field Calculator.
Type ppoint.x into the second text box, then select ok.
Click on the Ycoord column to select this column for editing, and then repeat the process used to calculate the Xcoord, except substitute ppoint.y for ppoint.x
Substitute ppoint.y for ppoint.x
On the Editor Toobar, select save edits and stop editing. In the Attribute Table, select Options, then Export.
For a visual spot check that the latitude-longitude information was correctly calculated, add the exported dbase table back onto ArcMap.
Using ArcMap Tools, select Add XY data, then select OK.
Hospital01 Events appear to overlay the Hospital01 points.
From the View Tool Bar, select Effects
Select the swipe button to check that the Hospital01.Shp features are under the Hospital01 Events.
Add the detailed county layer, and then zoom in to spot check selected hospital locations where you are familiar with the correct answer.
Some Additional Resources Wayne C. Exploring hospital distribution using ArcGIS. ArcUser October-December 2002. Available from: http://www.esri.com/news/arcuser/1002/files/hsa.pdf Neer T. The field calculator unleashed. April-June 2005. Available from: http://www.esri.com/news/arcuser/0405/files/fieldcalc_1.pdf ESRI. Working with features faster in ArcGIS 9.1. ArcUser July-September 2005. Available from: http://www.esri.com/news/arcuser/0705/91faster.html