A 592Kb PDF of this article as it appeared in the magazine—complete with images—is available by clicking HERE
Create a GIS point feature data set from an ASCII file, and then relate each point to a database record. The process described here works equally well with Excel spreadsheets with only minor differences on how the file is loaded into ArcMap.
Introduction
ASCII (the American Standard Code for Information Interchange) is commonly used format for exchanging computer data. The ASCII has been in use since the 1960s and has been used in GIS for about that long. ASCII formatted data files are a common export/import option on most surveying software as well. In the GIS realm ASCII formats are used for a variety of raster and vector data. GIS software may read some ASCII formatted data directly, or may import or export the ASCII formatted data to other GIS formats. This article explains how to use an ASCII formatted point dataset in GIS and how to convert the ASCII point data to a GIS format (such as a shapefile or geodatabase feature class) with attributes.
With ESRI’s ArcMap one can easily load a delimited text file for display in geographic space provide that the text file has the following elements (see Fig.1):
1. X coordinate and Y coordinate as numeric values. The coordinates may be geographic or project coordinates, although geographic coordinates cannot be in degree, minutes, seconds (DMS) format (that format is non-numeric). If your coordinates are in DMS format, you must convert those to decimal degrees. Other numeric coordinate formats are acceptable so long as the GIS software understands the spatial reference and units. Projected coordinates such as UTM meters, or State Plane feet will work as well.
2. ArcMap expects the first row to contain the header and it does not provide a means to designate any other row as the header. Therefore, the first row will be treated by ArcMap as the header row. The header row identifies the field names including which fields contain the X (or easting) coordinate and Y (or northing) coordinate. The headers will be used as field names so they must conform to the ten-character limitation with no spaces or special characters in the name. The header row must be the first row in the file (see Fig. 2).
Optionally, the file may have an ObjectID field as a numeric data type for unique identifiers for each record. If the ObjectID field exists, then you will be able to perform a few basic spatial functions on the data such as selecting points on the map. All other fields, as listed in the header row in the file, will be treated as attributes for which each record.
View and Prepare the File Format
The sample file shown in Fig. 2 is a comma delimited text file, which means that a comma defines the separation between fields in each row. In addition, each row is treated as an individual record, so the number of rows equals the number of records. If an individual record has no value for a particular field, then there will be no data between the delimiters. In this sample dataset that would look like two commas with nothing between them.
Since our sample dataset has a couple extra lines before the header row we must remove the two extra lines at the top of the file. You can do this with any text editor such as Notepad, which can save in ASCII format. Be careful not to use word processing software that would change the file format.
Add the Points to ArcMap
After editing the file to remove the first two lines, the file is now ready to add to ArcMap.
In ArcMap we use TOOLS –> Add X Y Data, browse for my ASCII file with the .txt extension (see Fig. 3). This utility allows us to browse for the file, designate which field contains the X coordinates and which field contains the Y coordinates, and specify the coordinate system of our X and Y coordinates. It is very important to specify the correct coordinate system, datum, projection, and coordinate units, as the spatial reference defines the proper placement of the points into geographic space.
After you set all the parameters in the Add XY Data dialog box and click OK, then ArcMap reads in each line of the file, and creates a point graphic on the screen for each record if the coordinates make sense (see Fig 4). The point graphics are based on the XY coordinates, and all other data are treated as attributes for each point (see Fig. 5).
The Add XY Data process adds the ASCII point data as an event theme in ArcMap. Event themes are not a GIS type, but rather a virtual geographic interpretation with a linkage to the data in the ASCII file. The original ASCII file is still intact with no changes to it. ArcMap is merely reading and interpreting the text file for display in ArcMap. The graphics and attributes are available for view only in the ArcMap project in which the event theme was created. It is not available as a GIS dataset for any other application. However, once you add the ASCII file to ArcMap as an event theme, you can add other GIS layers to the map and everything should properly align.
Convert to GIS format
To create a GIS dataset from the event theme, you must export the event theme to a shapefile or to a feature class in a geodatabase. To export to a GIS dataset, right click on the event theme layer in the map’s table of contents, then select Export from the list of options. This will initiate the Export dialog (see Fig. 6) which allows you to save as a GIS dataset with the file name of your choice and, optionally, to change the spatial reference as well. The result of the export operation will be a new file such as a shapefile. This operation does not make any changes to the original ASCII file. The new GIS file will be immediately available to use in any number of GIS display and analysis operations.
Rj Zimmer is Director of GIS and Mapping for DJ&A, PC of Montana, an engineering, surveying, and mapping consulting company.
A 592Kb PDF of this article as it appeared in the magazine—complete with images—is available by clicking HERE