comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: ERDAS format conversion
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: ERDAS format conversion [message #2726] Mon, 29 August 1994 09:19
8015 is currently offline  8015
Messages: 52
Registered: November 1993
Member
In article <33l0uaINNeu2@maz4.sma.ch>,
Ola ENGELSEN <ola.engelsen@cen.jrc.it> wrote:
> idlusers-news-gateway:
> id AA21780; Fri, 26 Aug 94 17:16:47 +0200
> id AA08274; Fri, 26 Aug 94 17:15:06 +0200
> id AA10955; Fri, 26 Aug 1994 17:18:47 +0200
>
>
> How do I convert image data in the ERDAS image processing system to an IDL
> compatible data format like XDR, binary with no header?
>

Here's a read_erdas program I put together a short time ago. Call the
program with the name of the erdas file and a data variable. The data
variable will be returned with the data from the erdas file. It's
supposed to work just like the other read_* programs available in the
User Library. It's been tested on exactly one data set, so no
guarantees.

The data variable can be writeu'd to a file without a header using
whatever format you like.

;########################################################### ##################
; Hughes Santa Barbara Research Center #
; Copyright 1994 - Hughes/GM #
;########################################################### ##################
; File Name: read_erdas.pro
; Version: 1.1
; Author: Mike Schienle
; Orig. Date: 94-06-20
; Delta Date: 8/15/94 @ 08:12:07
;########################################################### ##################
; Purpose:
; History:
;########################################################### ##################
; @(#)read_erdas.pro 1.1
;########################################################### ##################

; usage: read_erdas, filename, data variable (may be empty)
pro read_erdas, infile, data
; erdas header is 128 bytes long
erdas_header = bytarr(128)
; open the input file, check for errors
openr, ilun, infile, /get_lun, error=err
if (err ne 0) then begin
; error reading file
print, 'Error reading ' + infile
return
endif else begin
; read file header into header variable
readu, ilun, erdas_header
if (string(erdas_header(0:5)) ne 'HEAD74') then begin
; check to see if data is from an erdas file
print, 'Non-ERDAS header: ' + string(erdas_header(0:5))
return
endif else begin
; check data type (byte, int)
dtype = erdas_header(7)
; get X dimension (samples)
xdim = (erdas_header(17) * 256L) + erdas_header(16)
; get Y dimension (lines)
ydim = (erdas_header(21) * 256L) + erdas_header(20)
; get Z dimension (number of bands)
nband = erdas_header(8)
case dtype of
0: dstr = 'bytarr'
2: dstr = 'intarr'
else: begin
print, 'Unsupported data type - 4 bit'
return
end
endcase
; create the data array
cmd = 'data = ' + dstr + '(xdim,ydim,nband,/nozero)'
check = Execute(cmd)
; create a block array
cmd = 'dblock = ' + dstr + '(xdim,nband,/nozero)'
check = Execute(cmd)
for i = 0, (ydim - 1) do begin
; read in each block and fill the data array
readu, ilun, dblock
data(*,i,*) = dblock
endfor
endelse
endelse
; free the LUN
free_lun, ilun
end

Mike Schienle Hughes Santa Barbara Research Center
8015@sbsun0010.sbrc.hac.com 75 Coromar Drive, M/S B28/87
Voice: (805)562-7466 Fax: (805)562-7881 Goleta, CA 93117
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: How to test for the existance of a director
Next Topic: Re: CORBA and IDL

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:37:07 PDT 2025

Total time taken to generate the page: 0.00498 seconds