« Back to Video Tutorials

Converting Shapefiles to PLT Using PyTecplot


Description

In this video, we introduce the use of shapefiles in Tecplot 360. For datasets that represent a geographic region, a shapefile can give additional context to help communicate the location of your data. In this video we’ll demonstrate the use of a Python script to convert a shapefile to Tecplot binary data format.

Here we are looking at pressure contours from a simulation of Hurricane Katrina. Without knowing it is hurricane Katrina, it’s difficult to tell where we are in the world. A shapefile will help make the region we are looking at more obvious.

Prerequisites are that you have a 64-bit version of Python and the PyTecplot and pyshp (Pyshape) Python modules installed. From a command prompt execute the script as such:

shapefile_to_plt.py USA_adm1.shp USA_adm1.plt

The script will then prompt you for additional information.

  1. Convert to a single zone or one zone per shape. In this case we have a shapefile that represents the entire United States where each state is a separate shape. If we convert this file to one zone per shape, we will have one zone per state. This will allow us to turn on and off individual states and color them differently. Select option #2.
  2. Choose the variable names to use. Note that this script does not make any coordinate transformations. If your shapefile is in UTM or Stateplane, it’s likely that you’re displaying your data using X/Y variables – so you should select X/Y. If your shapefile is in longitude/latitude coordinates you should select lon/lat as the exported variable names. In this case our shapefile is in lon/lat and we are displaying our data in lon/lat as well, so select option #2.
  3. Finally, when choosing a separate zone per shape, the script will also prompt you for which shapefile record column to use to name the zones. It will display the column name and the first shape file entry. This selection is critical to identify each shape while in Tecplot 360. In this case we’ll choose option #5 which will give each shape the name of the state.

Now that we’ve converted the shapefile to Tecplot PLT format we can append it to the dataset.

  • File > Load Data
  • Browse to the PLT file
  • Append data to active frame
  • Match lon/lat to XLONG and XLAT respectively

Now that the shapefile data is loaded we will activate the Mesh layer so we can see the shapefile information. This presents a much clearer picture of the region and the path of the hurricane. If we fit the data to the screen, we can see the entire United States. Because we imported each state as a separate zone, we can deactivate any zones that are outside of our region of interest.

This concludes the tutorial on using shapefiles in Tecplot 360.

Thank you for watching!

Try Tecplot 360 for Free

Related Videos