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!



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 >

NV5 at ESA’s Living Planet Symposium 2025

NV5 at ESA’s Living Planet Symposium 2025

9/16/2025

We recently presented three cutting-edge research posters at the ESA Living Planet Symposium 2025 in Vienna, showcasing how NV5 technology and the ENVI® Ecosystem support innovation across ocean monitoring, mineral exploration, and disaster management. Explore each topic below and access the full posters to learn... Read More >

Monitor, Measure & Mitigate: Integrated Solutions for Geohazard Risk

Monitor, Measure & Mitigate: Integrated Solutions for Geohazard Risk

9/8/2025

Geohazards such as slope instability, erosion, settlement, or seepage pose ongoing risks to critical infrastructure. Roads, railways, pipelines, and utility corridors are especially vulnerable to these natural and human-influenced processes, which can evolve silently until sudden failure occurs. Traditional ground surveys provide only periodic... Read More >

Geo Sessions 2025: Geospatial Vision Beyond the Map

Geo Sessions 2025: Geospatial Vision Beyond the Map

8/5/2025

Lidar, SAR, and Spectral: Geospatial Innovation on the Horizon Last year, Geo Sessions brought together over 5,300 registrants from 159 countries, with attendees representing education, government agencies, consulting, and top geospatial companies like Esri, NOAA, Airbus, Planet, and USGS. At this year's Geo Sessions, NV5 is... Read More >

1345678910Last
«October 2025»
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678
10871 Rate this article:
No rating

Overloading Objects in IDL

Anonym

One semester in college, I attended an informal class on object oriented programming in Python. On the first day, the professor asked if any of us had experience in object oriented programming. I told him that I use IDL, and he laughed me off and said, "IDL is not a real object oriented language." 

I personally think that IDL has many object oriented capabilities, and I'm still new techniques. Because IDL is an interpreted language, I have to say that it is very easy to develop classes, and object oriented programming in IDL is certainly nothing to be afraid of.

In this week's IDL Data Point article, I will discuss overloading operators of existing classes. Any object in IDL, including ones provided in the installation, can be overloaded by writing a new object class that uses inherits in the object class definition. In fact, some objects, such as IDL_OBJECT, are designed for the purpose of being overloaded.

Here is an example I made up: I want to use a list, but I want my list to do a little bit more than the simple LIST object in IDL (note that IDL's documentation specifies the lists and hashes as "compound data types," but underneath the hood, they are simply object classes). This fancy list will only allow numbers to be added. It must also have the ability to multiply every value by a specified factor, as well as the ability to increment all values by one.

Define the Class

For a lack of a better name, I will call this new list a "Fancy_List." The definition would look like this:

 

pro Fancy_List__Define
  
  !null = {Fancy_List, inherits List}
  
end

 

"Fancy_List" is now defined as a subclass as a list. 

 

fl = Obj_New('Fancy_List')
PRINT, Isa(fl, 'List')

IDL prints 1.

This means that a fancy list is a list, and a very fancy one at that.

Overload the ::Add Method

Since this list should only allow numeric values, the Add method needs to be overloaded. This can be done by writing a method Fancy_List::Add. In this example, any value passed in that is not a number will be quietly ignored. After performing the check, the code then calls down to the superclass ::Add method. Keywords are simply passed through via _REF_EXTRA (this is used instead of _EXTRA so that unnecessary copies of keywords are not made).

 

pro Fancy_List::Add, value, index, _REF_EXTRA=extra
  
  if ~Isa(value, /NUMBER) then return
  
  self.List::Add, value, index, _EXTRA=extra
  
end

 

Implement a ::Multiply Method

I will write a new method called ::Multiply that multiplies every value by a given factor. This method name is unique to the fancy list, since LIST does not have such a method, so it does not overload anything.

 

pro Fancy_List::Multiply, multiplier
  
  for i=0, self.Count()-1 do begin
    self[i] *= multiplier
  endfor
  
end

Overload Operators

Since List inherits IDL_Object and Fancy_List inherits List, then the fancy list can overload any of IDL_Object's operators. Here is an example of overloading the ++ operator. This operation will increment every value in the fancy list by one.

 

pro Fancy_List::_overloadPlusPlus
  
  for i=0, self.Count()-1 do begin
    self[i]++
  endfor
  
end

 

Example in Action

Now that it's all assembled, let's click the Compile button and try it out!

fl = Fancy_List()
fl.Add, 'A'
print, fl.Count()

IDL prints 0, since the fancy list ignored the string value 'A.'

fl.Add, [1,2,3,4], /EXTRACT
PRINT, fl

IDL prints:

       1
       2
       3
       4

 

fl.Multiply, 2

PRINT, fl

IDL prints:

       2
       4
       6
       8

fl++
PRINT, fl

IDL prints:

       3
       5
       7
       9

 

Please login or register to post comments.