18.104.22.168. Importing XY data from text files
Many people work with spatially related data even without recognizing it, for example when dealing with observation or address data from multiple locations. It is easy to make use of spatial information also from data stored in text files, calculation spreadsheets or any database. Often, point data representing X, Y, and sometimes Z (altitude) coordinates in the real world are contained within text files and can be imported into ArcMap as an Excel spreadsheet (*.xls or *.xlsx), a text file (*.txt), or comma separated value (*.csv) file. To ensure that this is done without problems or annoyances, ensure the data are properly formatted. For example, the field names in the header line of the text file should not use spaces or special characters, nor should the filename.
To add points from a text file (Fig. 15):
- Go to File.
- Select Add Data.
- Select Add XY Data.
- Browse to the GISBEEBOOK folder.
- Double-click the colony_locations.xlsx file.
- Double-click Sheet1$.
- Choose the respective fields that hold the X and Y data (or longitude
and latitude, depending on which coordinate system is used). If the file
contains altitude information, add that field in the Z field. In this case:
a. X Field: POINT_X
b. Y Field: POINT_Y
- The coordinate system has already been defined for this layer.
- Click OK.
It is important to note that this layer is loaded into ArcGIS and available for any display and map creation purpose and also some basic analysis, but not physically stored as geodata in the file system. A warning dialog box (Fig. 16) may appear which indicates that the created layer will have to be exported to a shapefile if all functionalities are needed.
- Click OK.
Now the points can be seen in the map and the layer can be seen in the TOC.
- Right-click the “Sheet1$ Events” layer in the TOC.
- Select Data.
- Select Export Data to export these temporary points and make a permanent shapefile.
- Choose to use the layer’s source data as the correct coordinate system should have already been set in the previous steps.
- Browse to the GISBEEBOOK/ArcGIS folder to name the files intuitively, for example, we will name this layer colony_locations.
- Save as type: Shapefile.
- Click OK.
- Click Yes when asked to display the new layer on the map.
- Remove the Sheet1$ Events layer by right-clicking on Sheet1$ Events layer.
- Select Remove. We now have the permanent shapefile, so this temporary layer is no longer needed (Fig. 17).
To change the symbology of the point layer to make the points more
a. Single-click on the symbol in the TOC and choose the new symbol and size.
b. Go into the properties of the layer by right-clicking Layer.
c. Select Properties.
d. Click the Symbology tab.
e. Change the symbol to a yellow circle for example.
f. Click OK.
Also to note, there are multiple symbol libraries that can be added by clicking the Style References button when in the Symbol Selector dialog box. The symbol libraries provide more options for symbol styles.
Fig. 15. The “Add XY Data” dialog box.
Fig. 16. The warning dialog box produced which states that the table does not have an Object-ID field when adding a table to ArcMap.
Fig. 17. A visualization of the colony location point data in ArcMap.