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
15209 Rate this article:
4.5

ENVI: Adding custom polygons to the display

Anonym

A recent project I worked on required custom polygons – Controlled by my application – to be added to the ENVI display.  The following code defines an object class that allows the user to place a polygon in the ENVI display using window coordinates.  To run the application:

  1. Save the code that follows to a file named envi_polygon_example.pro
  2. Open and compile the file in the IDLDE
  3. Execute the following at the IDL command prompt

  4. envi_polygon_example

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

;+

; Lifecycle method for destroying the object

;-

pro my_polygon::Cleanup

  compile_opt idl2, logical_predicate

  self->Destruct

end

 

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

;+

; Cleans up the member variables of the object class

;-

pro my_polygon::Destruct

  compile_opt idl2, logical_predicate

  self->IDLmiManipGraphicOverlay::Cleanup

  self->IDLmiManipLayer::Cleanup

  self->IDLgrPolygon::Cleanup

end

 

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

;+

; Lifecycle method for initializing the class

;

; :Returns:

;   1 if the object initializes successfully and 0 otherwise

;  

; :Params:

;   xy: in, optional, type="int"

;     a [2,n] array containing the [x,y] points in window coordinates

;  

; :Keywords:

;   POLYGONS: in, optional, type="int"

;     An integer array of one or more polygon descriptions.  See IDL help for

;     IDLgrPolygon for more information

;   _REF_EXTRA: Used to set properties of the inherited IDLgrPolygon

;-

function my_polygon::Init, xy, $

  POLYGONS=poly, $

  _REF_EXTRA=refExtra

  compile_opt idl2, logical_predicate

  void = self->IDLmiManipGraphicOverlay::Init(_EXTRA=refExtra)

  if ~void then begin

    return, 0

  endif

  self->InitializeDataspace

  self->SetupManipulatorGraphics

  self->InitializeGraphics

  if n_elements(xy) then begin

    self->SetProperty, DATA=xy, POLYGONS=poly

  endif

  if n_elements(refExtra) then begin

    self->SetProperty, _EXTRA=refExtra

  endif

  return, 1

end

 

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

;+

; This method initializes the data space used by the graphics layer

;-

pro my_polygon::InitializeDataspace

  compile_opt idl2, logical_predicate

  e = envi(/CURRENT)

  eView = e->GetView()

  eView->GetProperty, _COMPONENT=ecfViewGroup

  oDS = ecfViewGroup->GetDescendants(BY_TYPE='DATASPACE', /FIRST_ONLY)

  self._oTargetDS = oDS

end

 

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

;+

; Initializes the graphics components of the class

;-

pro my_polygon::InitializeGraphics

  compile_opt idl2, logical_predicate

  void = self->IDLgrPolygon::Init(COLOR=[255,0,0], /PRIVATE, THICK=2)

  self._oGrOverlay->IDLmiContainer::Add, self

end

 

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

;+

; This method is for setting class properties

;-

pro my_polygon::SetProperty, $

  DATA=data, $

  POLYGONS=poly, $

  _REF_EXTRA=refExtra

  compile_opt idl2, logical_predicate

  if n_elements(data) then begin

    self->SetData, data, POLYGONS=poly

  endif

  if n_elements(refExtra) then begin

    self->IDLgrPolygon::SetProperty, _EXTRA=refExtra

    self->IDLmiManipLayer::SetProperty, _EXTRA=refExtra

  endif

end

 

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

;+

; This method maps the points from window coordinates to map coordinates and

; adds the mapped points to the IDLgrPolygon.

;

; :Params:

;   xy: in, required, type="int"

;     A [2,n] array of points (In window coordinates) to be added to the polygon

;

; :Keywords:

;   POLYGONS: in, optional, type="int"

;     An integer array of one or more polygon descriptions.  See IDL help for

;     IDLgrPolygon for more information

;-

pro my_polygon::SetData, xy, $

  POLYGONS=poly

  compile_opt idl2, logical_predicate

  self._oTargetDS->WindowToVis, reform(xy[0,*]), reform(xy[1,*]), xVis, yVis

  self->IDLgrPolygon::SetProperty, DATA=transpose([[xVis],[yVis]]), $

    POLYGONS=poly

end

 

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

;+

; Class structure definition

;-

pro my_polygon__define

  compile_opt idl2, logical_predicate

  void = {my_polygon                    $

    , inherits IDLmiManipGraphicOverlay $

    , inherits IDLmiManipLayer          $

    , inherits IDLgrPolygon             $

    }

end

 

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

;+

;-

pro envi_polygon_example

  compile_opt idl2, logical_predicate

  e = envi(/CURRENT)

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

    e = envi()

  endif

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

  eRaster = e->OpenRaster(file)

  eView = e->GetView()

  eLayer = eView->CreateLayer(eRaster)

  xy = [[470,140],[560,140],[560,230],[470,230], $

    [750,115],[1200,115],[1200,665],[750,665]]

  conn = [4,0,1,2,3,4,4,5,6,7]

  oPolygon = obj_new('my_polygon', xy, LINESTYLE=5, POLYGONS=conn, STYLE=1)

end

Please login or register to post comments.