11

I'm a Pythonist in an office full of ENVI/IDL users. I've created some tools to help bridge the gap, but one big stumbling block is ENVI Classic .roi files, which my colleagues use a lot.

I can easily import ENVI 5 ROIs into Python, since the text-based format is easy to parse. However, I don't have a good sense for the binary format of ENVI Classic .roi files, which make up the bulk of data interchange in my group. Does anyone have any code that reads or writes these files, or any insight on how one might go about it?

It's somewhat tedious to fire up ENVI 5 every time I want to go back and forth - I'd rather solve the problem at the source if possible.

1

I'm no python expert, but this should be relatively easy to do if you're already writing scripts that can parse, read, and write standardized ASCII files.

According to Harris Geospatial Solutions, the current developer of ENVI, ENVI binary image files (described here) should consist of the binary file and an ASCII header file (defined with example here). To read an ENVI image file, you'll need to parse the ASCII header and access the data type (integer, float, signed/unsigned, etc.), number of bands, the interleave (Band Sequential, Band-interleaved-by-pixel, or Band-interleaved-by-line), byte order, and any other pertinent data information. Take a close look at the header file format description and example linked to above.

Now that you know what chunks of the binary to read at a time, what order they are in, and which bands they belong to, you're ready to read the image data.

  • Are ENVI ROIs stored as image files? I guess they have "the same spatial size as their parent rasters" according to Harris Geospatial, but in the UI, half-pixels (diagonally bisected) are selected during dragging to create an ROI, so it seems like this would have to be a vector format of some sort, unless there is some sort of two-bit raster flag (to specify direction of the triangle). Anyway, I'll try as you suggest and see how far I get! – Daven Quinn Jun 8 '17 at 23:57
  • I think the "ENVI binary image files" are a pair of files, one with no extension and one with extension ".hdr". But, the .roi files seem to be in a different binary format? By the way, if all you want to do is load the .hdr file, use this python package: spectralpython.net – MD004 Jul 20 '17 at 0:21
  • Nope, I am definitely looking for a solution to read/write the ROIs directly, not just the headers, which can be read with e.g. GDAL depending on the format... – Daven Quinn Sep 2 '17 at 21:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.