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!



From Image to Insight: How GEOINT Automation Is Changing the Speed of Decision-Making

From Image to Insight: How GEOINT Automation Is Changing the Speed of Decision-Making

4/28/2025

When every second counts, the ability to process geospatial data rapidly and accurately isn’t just helpful, it’s critical. Geospatial Intelligence (GEOINT) has always played a pivotal role in defense, security, and disaster response. But in high-tempo operations, traditional workflows are no longer fast enough. Analysts are... Read More >

Thermal Infrared Echoes: Illuminating the Last Gasp of a Dying Star

Thermal Infrared Echoes: Illuminating the Last Gasp of a Dying Star

4/24/2025

This blog was written by Eli Dwek, Emeritus, NASA Goddard Space Flight Center, Greenbelt, MD and Research Fellow, Center for Astrophysics, Harvard & Smithsonian, Cambridge, MA. It is the fifth blog in a series showcasing our IDL® Fellows program which supports passionate retired IDL users who may need support to continue their work... Read More >

A New Era of Hyperspectral Imaging with ENVI® and Wyvern’s Open Data Program

A New Era of Hyperspectral Imaging with ENVI® and Wyvern’s Open Data Program

2/25/2025

This blog was written in collaboration with Adam O’Connor from Wyvern.   As hyperspectral imaging (HSI) continues to grow in importance, access to high-quality satellite data is key to unlocking new insights in environmental monitoring, agriculture, forestry, mining, security, energy infrastructure management, and more.... Read More >

Ensure Mission Success With the Deployable Tactical Analytics Kit (DTAK)

Ensure Mission Success With the Deployable Tactical Analytics Kit (DTAK)

2/11/2025

In today’s fast-evolving world, operational success hinges on real-time geospatial intelligence and data-driven decisions. Whether it’s responding to natural disasters, securing borders, or executing military operations, having the right tools to integrate and analyze data can mean the difference between success and failure.... Read More >

How the COVID-19 Lockdown Improved Air Quality in Ecuador: A Deep Dive Using Satellite Data and ENVI® Software

How the COVID-19 Lockdown Improved Air Quality in Ecuador: A Deep Dive Using Satellite Data and ENVI® Software

1/21/2025

The COVID-19 pandemic drastically altered daily life, leading to unexpected environmental changes, particularly in air quality. Ecuador, like many other countries, experienced significant shifts in pollutant concentrations due to lockdown measures. In collaboration with Geospace Solutions and Universidad de las Fuerzas Armadas ESPE,... Read More >

1345678910Last
«May 2025»
SunMonTueWedThuFriSat
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567
15382 Rate this article:
5.0

ENVI Extensions: Getting notifications from ENVI ROIs

Anonym

A recent project I worked on required an ENVI extension to respond ROI changes made in the ENVI Layer Manager.   Fortunately, ENVI provides a mechanism that allows an object to do this.  First, the object must be added to the list of observers for each ROI layer.  The following command provides access to these layers:

IDLcf$Get , /INCLUDE_VIS_CHILDREN, VIS_LAYERS=oVisLayers

The variable oVisLayers will contain all visible layers present in the ENVI display.  To get only the ROIs, loop through its contents looking for any instances of IDLcfVisROINative.  When one is encountered the object can be added to the ROI layer’s list of observers using the following:

void = oVisLayers[i]-> AddObserver (self)

Now that the object has been added to the list of observers an OnNotify method must be added.  Any notifications from the ROI layers will be sent to this method.

function my_class ::OnNotify, oSubject, strMsg, strArg

The input parameters are:\

  • oSubject – A reference to the ENVI object sending the notification
  • strMsg – A string containing the name of the notification (e.g. SETPROPERTY)
  • strArg – A string containing additional notification information (e.g. HIDE)

Here is a stand-alone example that demonstrates setting up an object to receive and act on notifications from ROIs in the ENVI Layer Manager:

;##############################################################################

; This example demonstrates how to get notifications from ENVI when changes are

; made to ROIs in the Layer Manager.

;##############################################################################

;------------------------------------------------------------------------------

;+

; Event handler used by XMANAGER

;

; :Params:

;   sEvent: in, required, type="struct"

;     An IDL event structure

;-

pro roi_demo_event, sEvent

  widget_control, sEvent.top, GET_UVALUE=oRoiDemo

  oRoiDemo->Event, sEvent

end

;------------------------------------------------------------------------------

;+

; Checks ENVI for any ROIs.  DIsplays all of the ROIs found in the message

; text box.

;

; :Keywords:

;   PREFIX: in, optional, type="string"

;     A string or string array of text to be added to the beginning of the ROI

;     message.

;-

pro roi_demo::CheckROIs, $

  PREFIX=prefix

  compile_opt idl2, logical_predicate

  IDLcf$Get, /INCLUDE_VIS_CHILDREN, VIS_LAYERS=oVisLayers

  name = []

  for i = 0, n_elements(oVisLayers)-1 do begin

    if isa(oVisLayers[i], 'IDLcfVisROINative') then begin

      void = oVisLayers[i]->AddObserver(self)

      oROI = oVIsLayers[i]->GetParameter('ROI')

      if obj_valid(oROI) then begin

        name = [name, oROI.name]

      endif

    endif

  endfor

  if (n_elements(prefix) EQ 0) then prefix = 'ROIs found:'

  str = [prefix,(n_elements(name) GT 0) ? name : 'No ROIs found']

  widget_control, widget_info(self.tlb, FIND_BY_UNAME='text_message'), SET_VALUE=str

end

;------------------------------------------------------------------------------

;+

; Creates a dialog for displaying information regarding the ENVI ROIs

;-

pro roi_demo::Dialog

  compile_opt idl2, logical_predicate

  e = envi(/CURRENT)

  self.tlb = widget_base(/COLUMN, /FLOATING, GROUP_LEADER=e.widget_id, $

    TITLE='ENVI ROI Demo')

  xSize = 100

  wLabel = widget_label(self.tlb, /ALIGN_LEFT, VALUE='Notification Information')

  wText = widget_text(self.tlb, UNAME='text_params', XSIZE=xSize, YSIZE=3)

  wLabel = widget_label(self.tlb, /ALIGN_LEFT, VALUE='ROI Information')

  wText = widget_text(self.tlb, UNAME='text_message', XSIZE=50, YSIZE=10)

  wBase = widget_base(self.tlb, /ALIGN_RIGHT, /ROW)

  wButton = widget_button(wBase, UNAME='check_roi', VALUE='Check ROIs')

  widget_control, self.tlb, /REALIZE, SET_UVALUE=self

  self->CheckROIs

  xmanager, 'roi_demo', self.tlb, /NO_BLOCK

end

;------------------------------------------------------------------------------

;+

; Event handler for the ROI demo's dialog

;

; :Params:

;   sEvent: in, required, type="struct"

;     An IDL event structure

;-

pro roi_demo::Event, sEvent

  compile_opt idl2, logical_predicate

  case widget_info(sEvent.id, /UNAME) of

    'check_roi': self->CheckROIs

    else: print, widget_info(sEvent.id, /UNAME)

  endcase

end

;------------------------------------------------------------------------------

;+

; Lifecycle method for initializing the object

;

; :Returns:

;   1 if the object initializes successfully and 0 otherwise

;-

function roi_demo::Init, $

  _REF_EXTRA=refExtra

  compile_opt idl2, logical_predicate

  if (~self->IDLmiObserver::Init(_EXTRA=refextra)) then begin

    print, 'Failed to initialize IDLmiObserver'

    return, 0

  endif

  return, 1

end

;------------------------------------------------------------------------------

;+

; This method is for receiving notifications from the notifiers for which this

; class is an observer.

;

; :Returns:

;   1

;

; :Params:

;   oSubject: in, required, type="objref"

;     The ENVI object that is sending the notifications

;   strMsg: in, required, type="string"

;     The notification string (e.g. SETPROPERTY)

;   strArg: in, required, type="string"

;     A string containing additional notification information (e.g. HIDE)

;-

function roi_demo::OnNotify, oSubject, strMsg, strArg

  compile_opt idl2, logical_predicate

  oSubject->GetProperty, NAME=name

  help, oSubject, OUTPUT=strHelp

  widget_control, widget_info(self.tlb, FIND_BY_UNAME='text_params'), $

    SET_VALUE=[strHelp, 'STRMSG: '+strMsg, 'STRARG: '+strArg]

  str = ''

  case strupcase(strMsg) of

    'ADDITEMS': begin

      str = ['Adding a new ROI','Press Check ROIs when finished']

    end

    'REMOVEITEMS': begin

      self->CheckROIs, PREFIX=['ROI has been removed','Remaining ROIs:']

      return, 1

    end

    'ROI_DEFINITION_CHANGE': begin

      str = name+' has been updated'

    end

    'SETPROPERTY': begin

      case strupcase(strArg) of

        'COLOR': begin

          oROI = oSubject->GetParameter('ROI')

          oROI->GetProperty, COLOR=color

          str = name+' color changed to '+strjoin(strtrim(fix(color),2),',')

        end

        'HIDE': begin

          oSubject->GetProperty, HIDE=hide

          str = name+' has been '+(hide ? 'hidden' : 'shown')

        end

        else:

      endcase

    end

    else: print, 'MESSAGE: '+strMsg

  endcase

  wText = widget_info(self.tlb, FIND_BY_UNAME='text_message')

  widget_control, wText, SET_VALUE=str

  return, 1

end

;------------------------------------------------------------------------------

;+

; Class structure definition

;

; :Inherits:

;   IDLmiObserver

;  

; :Fields:

;   tlb: This widget ID of the dialog's top level base.

;-

pro roi_demo__define

  compile_opt idl2, logical_predicate

  void = {roi_demo           $

   

    , inherits IDLmiObserver $

    , tlb  : 0L              $

   

      }

end

;------------------------------------------------------------------------------

;+

;-

pro roi_demo

  compile_opt idl2, logical_predicate

  e = envi(/CURRENT)

  if ~isa(e, 'envi') then begin

    e = envi()

    eView = e->GetView()

    file = Filepath('qb_boulder_msi', ROOT_DIR=e.root_dir, SUBDIRECTORY=['data'])

    eRaster = e->OpenRaster(file)

    eLayer = eView->CreateLayer(eRaster)

    file = Filepath('qb_boulder_roi.xml', ROOT_DIR=e.root_dir, SUBDIRECTORY=['data'])

    eROI = e->OpenROI(file)

    nROI = n_elements(eROI)

    eLayerROI = objarr(nROI)

    for i = 0, nROI-1 do begin

      eLayerROI[i] = eLayer->AddROI(eROI[i])

    endfor

  endif

  oROIDemo = obj_new('roi_demo')

  oROIDemo->Dialog

end

1 comments on article "ENVI Extensions: Getting notifications from ENVI ROIs"

Avatar image

Mobit Solutions

I did not understand the program in the middle. I'll go through it again and I'll definitely try this in my seo company.

Please login or register to post comments.