Skip to main content

Overview

ASCII files are plain text files that use ASCII character encoding, and which can store geospatial data. NASA offers some data products in ASCII format, including new data products from HAQAST. This document will explain how to open this file format in popular GIS software, ArcGIS Pro and QGIS. The process for both is very similar and any differences will be included as notes. Videos of this tutorial are available at the end.

Example

This example will use the NASA data product “HAQES_NA_PM25_TOT_CENSUS_1” to show the fine particulate matter (PM2.5) levels in each census tract across the United States on 11/1/2022.

 

Prerequisites

This example used ArcGIS Pro version 3.1.0 And QGIS version 3.28.10, as well as the Python package “pandas” for file conversion.

ArcGIS Pro is a desktop client. Individual ArcGIS Pro licenses can be acquired from Esri or can be accessed through an organization with Named user or concurrent use licenses. Other web based platforms, like ArcGIS Enterprise or ArcGIS Online (AGOL), provide limited free public access to GIS tools or services.

 

Procedure

1. Download one of the .txt files from NASA Earthdata Search.

2. Convert the .txt file to CSV using the following Python code snippet. This has been adapted from the "Options for Reading the Data" section in the Health and Air Quality Applied Science Team's (HAQAST) README file.

import pandas as pd
#Read data file
Data_file= r'\path\HAQAST_ASCII.txt'
df_census = pd.read_csv(Data_file,low_memory=False, dtype={"TRACT": "str"}, skiprows=20)
#save as csv
df_census.to_csv(r'path\HAQAST.csv')

3. Download the Census Tracts 1:500,000 (national), and the newly defined 2020 ZIP Code shapefile (as of February 8, 2022) as specified in the README: Cartographic Boundary Files (census.gov).

4. Add the census tract shapefile (cb_2020_us_tract_500k.shp) to the GIS map. This can be done simply in both ArcGIS Pro and QGIS by dragging and dropping the shp file onto the map or into the ArcGIS Contents pane or QGIS Layers pane. The contents of the shapefile can be viewed as an attribute table in both QGIS and ArcGIS by right-clicking the census tract layer in the QGIS Layers or ArcGIS Contents pane, and selecting "Attribute Table" or "Open Attribute Table". See Figures 1 and 2 below for how this should appear in your GIS map.

Image
Image Caption

 Figure 1. Census tract shapefile in QGIS

Image
Image Caption

Figure 2. Census tract shapefile in ArcGIS Pro

 5. Add the HAQAST CSV file created from the above code to the map by dragging and dropping the file into the Layers or Contents pane. 

          a. This can be done simply in both ArcGIS Pro and QGIS by dragging and dropping the csv file onto the map or into the ArcGIS Contents pane or QGIS Layers pane. 

          b. For ArcGIS Pro, some modifications will have to be made to the CSV table in order for the next step (join) to be successful:

               i. First use the “Export Table” Geoprocessing tool to create a table from the CSV file. It is best to set the Output Table format as a File Geodatabase table (no file extension needed, stored inside a Geodatabase). Click Run.

Image
Image Caption

 Figure 3. Export Table geoprocessing tool in ArcGIS Pro

               ii. Right-click the new table layer in the Contents pane to open the attribute table. Then click Add in the open attribute table view to create a new field.

               iii. Create a new field here, called “GEOID”, to match the corresponding field in the census shapefile, and select the data type as “Text”, then right-click the new field and save.

Image
Image Caption

Figure 4. Fields table of the HAQAST attribute table in ArcGIS Pro

               iv. Return to the attribute table tab, right-click the new field that is filled with <Null>, and select Calculate Field. See Figure 5 below.

               v. As the input in the Calculate Field pane, double-click TRACT under the Fields list. Click Apply. This will convert the number in the TRACT field to a text string.

               vi. Next, remove the formula in the “GEOID =” [expression box]. This time, double-click the GEOID field and add the following function in the “GEOID =” [expression box]: .zfill(11). Click Apply. This will add 0s at the beginning of the TRACT IDds so that each TRACT ID is exactly 11 digits. See Figure 6 below.

Image
Image Caption

Figure 5 (left), Figure 6 (right)

               vii. For future steps in ArcGIS Pro, you will use this new GEOID field.

6. Create a join between the CSV table and the census shapefile (join the table TO the shapefile). This merges the content from the HAQAST CSV file into the census shapefile's attribute table, resulting in an attribute table that will contain all the fields from both.

          a. For QGIS, search the Processing Toolbox (View > Panels > Check on "Processing Toolbox") for the "Join Attributes by Field Value" tool. Input the SHP and CSV as tables and join on the GEIOD and TRACT fields respectively. Click Run. A new layer will be created, called "Joined layer".

Image
Image Caption

 Figure 7. Join Attributes by Field Value tool in QGIS.

          b. For ArcGIS Pro, join the fields by right-clicking the census shapefile and selecting Joins and Relates > Add Join. Select the census shapefile and the HAQAST Export Table tool output (File Geodatabase table) as the Input and Join table, respectively. Then select the GEOID fields in both as the Join Fields. Click "OK".

Image
Image Caption

Figure 8. Add Join tool in ArcGIS Pro.

The census tract layer should now contain the fields from the HAQAST table.

7. In QGIS, you can confirm the join by selecting a census tract to view a pop-up with the attributes, now including PM2.5 values from the HAQAST CSV, using the Identify Features icon 

          a. To change the symbology in QGIS so that the color changes are based on the PM2.5 attribute, right-click the "Joined layer" and select Properties. Select the Symbology page on the left of the Properties pane. Then in the top drop-down menu, a Categorized color scheme based on the PM2.5 input will have a color ramp based on PM2.5 values. In Figure 9, the example uses blue for low PM2.5 values and red for high pmPM2.5 values (more instructions for changing the Symbology in QGIS may be found in How to Import Gridded (and Non-Gridded) NetCDF Data into QGIS).

Image
Image Caption

Figure 9: Selected census tract after join in QGIS

Note: This image is showing the joined layer with a new color scheme categorized by the PM2.5 attribute which is now visible in the values table on the right for the highlighted census tract.

          b. To change the Symbology in ArcGIS Pro, right-click the census shapefile layer and select Symbology. Select a Graduated Colors symbology and the Field PM2.5 with an appropriate color scale. This step may take several minutes to complete but will be faster if you export the Joined census layer by right clicking, then selecting Data > Export Features. 

Image
Image Caption

Figure 10. Modified Symbology of the census tract layer by PM2.5 in ArcGIS Pro.

          c. It is recommended to view the GIS data's PM2.5 values by the pre-defined Air Quality Index scale (AQI), which outlines ranges of 24-Hour PM2.5 Levels (μg/m3). This will give you a more accurate representation in the map of PM2.5 levels that are healthy or unhealthy according to the AQI scale for your area of study. The symbology panes in QGIS and ArcGIS Pro will give you options to make these adjustments by changing the symbology type. For a reference containing information on the AQI scale ranges, please visit: "What is PM2.5 and Why You Should Care" by Bliss Air.

 

Additional Info

Different ASCII files may require different shapefiles. For example, a different HAQAST product provides PM2.5 information based on county instead of census tract. In that case, you will have to download the county shapefile specified in the README instead, but all other steps should remain the same. Please confirm in the README file which shapefile is needed for your data.

Details

Last Updated

Dec. 2, 2026

Published

Dec. 1, 2020

Data Archive

Goddard Earth Sciences Data and Information Services Center (GES DISC)