X

NV5 Geospatial Blog

Each month, NV5 Geospatial posts new blog content across a variety of categories. Browse our latest posts below to learn about important geospatial information or use the search bar to find a specific topic or author. Stay informed of the latest blog posts, events, and technologies by joining our email list!



Comparing Amplitude and Coherence Time Series With ICEYE US GTR Data and ENVI SARscape

Comparing Amplitude and Coherence Time Series With ICEYE US GTR Data and ENVI SARscape

12/3/2025

Large commercial SAR satellite constellations have opened a new era for persistent Earth monitoring, giving analysts the ability to move beyond simple two-image comparisons into robust time series analysis. By acquiring SAR data with near-identical geometry every 24 hours, Ground Track Repeat (GTR) missions minimize geometric decorrelation,... Read More >

Empowering D&I Analysts to Maximize the Value of SAR

Empowering D&I Analysts to Maximize the Value of SAR

12/1/2025

Defense and intelligence (D&I) analysts rely on high-resolution imagery with frequent revisit times to effectively monitor operational areas. While optical imagery is valuable, it faces limitations from cloud cover, smoke, and in some cases, infrequent revisit times. These challenges can hinder timely and accurate data collection and... Read More >

Easily Share Workflows With the Analytics Repository

Easily Share Workflows With the Analytics Repository

10/27/2025

With the recent release of ENVI® 6.2 and the Analytics Repository, it’s now easier than ever to create and share image processing workflows across your organization. With that in mind, we wrote this blog to: Introduce the Analytics Repository Describe how you can use ENVI’s interactive workflows to... Read More >

Deploy, Share, Repeat: AI Meets the Analytics Repository

Deploy, Share, Repeat: AI Meets the Analytics Repository

10/13/2025

The upcoming release of ENVI® Deep Learning 4.0 makes it easier than ever to import, deploy, and share AI models, including industry-standard ONNX models, using the integrated Analytics Repository. Whether you're building deep learning models in PyTorch, TensorFlow, or using ENVI’s native model creation tools, ENVI... Read More >

Blazing a trail: SaraniaSat-led Team Shapes the Future of Space-Based Analytics

Blazing a trail: SaraniaSat-led Team Shapes the Future of Space-Based Analytics

10/13/2025

On July 24, 2025, a unique international partnership of SaraniaSat, NV5 Geospatial Software, BruhnBruhn Innovation (BBI), Netnod, and Hewlett Packard Enterprise (HPE) achieved something unprecedented: a true demonstration of cloud-native computing onboard the International Space Station (ISS) (Fig. 1). Figure 1. Hewlett... Read More >

1345678910Last
12352 Rate this article:
No rating

Quick IDL Tricks

Anonym

In this edition of IDL Data Point, I will outline a few quick tips that I have learned throughout my experience of IDL programming.

KEYWORD_SET checks for empty strings

Although the main purpose of the KEYWORD_SET function is to check input parameters of a routine, it is also very useful for checking that a value is defined and nonzero. For example, KEYWORD_SET conveniently replaces the following two-expression line:

IF N_ELEMENTS(var) GT 0 && var NE 0 THEN ...

with one single expression:

IF KEYWORD_SET(var) THEN ...

Additionally, KEYWORD_SET will return 0 if a variable is an empty string. Similar to the expression above, the following two-line expression:

IF N_ELEMENTS(str) GT 0 && STRLEN(str) GT 0 THEN ...

can be replaced with this single expression:

IF KEYWORD_SET(str) THEN ...

!NULL to throw away a function result

Occasionally, you may want to use a function to make use of input-output parameters, but you may not care about the result. A good example is with the WHERE function:

result = WHERE(arr EQ 1, count)

In this expression, perhaps you don’t care about the actual position of the value 1, but instead you just want to know whether or not the value 1 is contained in the array; therefore, you will use the count but will never use the variable result again. Rather than carry this variable around, it can simply be thrown away by using !NULL, and IDL will never store it:

!NULL = WHERE(arr EQ 1, count)

This can also be used with the TEMPORARY function to dispose of an existing variable:

var = 1

!NULL = TEMPORARY(var)

help, var

VAR             UNDEFINED = <Undefined>

Not only is this useful for freeing memory, especially if the variable is very memory-intensive, this also helps debugging by temporarily capturing results from multiple functions in order to break expressions into multiple lines. For instance, the following line is difficult to debug because IDL will only step into one function; stepping out of the first function will return to the next line, and IDL will not step into the second function.

IF func1(var) && func2(var) THEN BEGIN

  ...

ENDIF

…and the following line has the same problem:

IF func1(func2(var)) THEN BEGIN

  ...

ENDIF

Instead, you can create a couple of temporary variables:

temp1 = func1(var)

temp2 = func2(var)

IF temp1 && temp2 THEN BEGIN

  ...

ENDIF

!NULL = TEMPORARY(temp1) & !NULL =TEMPORARY(temp2)

…and

temp1 = func2(var)

temp2 = func1(temp1)

IF temp2 THEN BEGIN

  ...

ENDIF

!NULL = TEMPORARY(temp1) & !NULL =TEMPORARY(temp2)

(Note that this is similar to DELVAR, but DELVAR is only a main-level routine and cannot be used within a routine).

 

Use RETURN or CONTINUE in place of an IF block

Sometimes code can be simplified by immediately leaving the current section of code rather than using a large conditional statement. Here are a couple of examples.

If the conditional statement is at the end of aroutine, like this

PRO myroutine

  ...

  IF(condition) THEN BEGIN

    ...

  ENDIF

END

you can simply return out of the procedure once the condition is determined to be untrue:

PRO myroutine

  ...

  IF(~condition) THEN RETURN

  ...

END

Similarly, CONTINUE can eliminate conditional blocks in loops:

FOR i=0,10 DO BEGIN

  IF(condition) THEN BEGIN

    ....

  ENDIF

ENDFOR

Instead:

FOR i=0,10 DO BEGIN

  IF(~condition) THEN CONTINUE

  ...

ENDFOR

 

Use SWITCH instead of multiple OR checks

Sometimes you may have a statement like this:

IF var EQ 1 || var EQ 5 || var EQ 8 || var EQ 11 THEN BEGIN

  ...

ENDIF ELSE IF var EQ 12 || var EQ 13 THEN BEGIN

  ...

ENDIF ELSE BEGIN

  ...

ENDELSE

Making use of SWITCH can avoid typing "var EQ" multiple times:

SWITCH var OF

  1:

  5:

  8:

  11: BEGIN

    ...

    BREAK

  END

  12:

  13: BEGIN

    ...

    BREAK

  END

  ELSE: BEGIN

    ...

  END

ENDSWITCH

Additional IDL tips

Additional tips for efficient programming can be found here:
Tips & Tricks for Efficient IDL Programming

Please login or register to post comments.