Golden Software Blog

Helping you learn more about the latest product information, tips, tricks, techniques, and customer stories so you can visualize data and communicate results with ease.

Color line segments by attribute value using Surfer’s Base Symbology

A Surfer user contacted me a while back asking how to color segments of a line with different colors based on the attribute value of the line. He had the line defined in a BLN file with a different Z value assigned to each x,y pair. This can be useful for visualizing downhole measurement values down a well or borehole, traffic speed along a road (similar to a Google Maps display, as shown below), or any measurement collected in a streaming fashion along a specific path.

​Google Maps displays traffic speed, where green is fast and dark red is slow. This helps commuters avoid areas of congestion as they drive to and from their destinations.​

I thought this sounded like a fun use of Surfer 15's new base symbology functionality, but there was a problem: base symbology colors the entire line based on one attribute value. Since we want to color the lines by the Z value attribute, it quickly became obvious that I'd need to write a script to split the polyline out into two-node line segments in order to get the desired effect. Attached is the resulting script, as well as a series of sample BLN files to run this on – Denver locals might be (painfully) familiar with highways Interstate I-25 and US Highway 6, which we are going to color by traffic speed. To run this script, the BLN files must contain only one line apiece, but there can be multiple BLN files in a single directory. 


To get a map like this, first run the script:

  1. Download the script from here. If desired, download the directory of BLN files from here (unzip the folder after it has downloaded).
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer 15.
  3. Double click on Scripter.exe to open Scripter.
  4. Click File | Open.
  5. Navigate to the directory where you saved the script, select the script, and click Open.
  6. In the USER DEFINED VARIABLES section (lines 8-15), change the in_dir file path to the location of your BLN files or the sample BLN files you have downloaded. Change the out_dir file path to the location you want the output BLN files to save to. These can be the same directory if desired.
  7. Click Script | Run to run the script.


After the script has finished, create the map:

  1. Click File | New | Plot Document.
  2. Click Home | New Map | Base.
  3. Select the first new BLN file in the output directory and click Open.
  4. Select the Base(vector) layer in the Contents window.
  5. Click Features | Group | Start Editing.
  6. Click File | Import.
  7. Select the second new BLN file in the output directory.
  8. Hold SHIFT and click the last new BLN file in the output directory.
  9. Click Open.
  10. Click Features | Group | Stop Editing.
  11. Select the Map.
  12. On the Limits page in the Properties window, check the box next to Use data limits.
  13. Select the Base(vector) layer in the Contents window.
  14. On the General page in the Properties window, click the Edit Symbology button.
  15. In the Symbology dialog, if you have discrete attribute values like we do, select Unique Values from the pane on the left.
  16. Set the Attribute field to the field containing the attributes you want to use to color your line segments (STD_ID1 in this case).
  17. Click the Add All button to add all unique attributes to the list.
  18. Click on each entry in the Line column for each attribute in the list, then edit the Line properties on the right.


The Sybmology dialog allows you to define the formatting of objects based on an attribute value.
 19. Click OK when you're done editing attributes to apply the change to the map. 
Interstate I-25 and US Highway 6 through Denver, CO have been color coded by traffic speed using Surfer’s base symbology feature, where green (1) is fast and dark red (4) is slow.

 20. If desired, with the Base(vector) layer still selected, click the Map Tools | Add to Map | Legend command to add a legend. Select the legend, click on the Layers tab in the Properties window, and edit the Template until it just shows \line \value.

Thanks to Surfer's useful scripting capabilities and the flexibility offered by the new base symbology functionality, you're able to create the visually-stunning output you could previously only dream about!

 

Comments

No comments made yet. Be the first to submit a comment
Guest
Sunday, 24 June 2018

Captcha Image

Subscribe To Our Blog

Most Popular

Over the years, one of the most common questions asked is “How can I get my contour map out of Surfe...
For more than 20 years, Surfer mapping software has been used by representatives of nearly all indus...
This week's new feature series is a tutorial on how to use the new coordinate system dialogs in MapV...

Exceeding expectations

Go to top